Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract.CommonDataKinds.Phone;

public class Main {
    public static final String getTelefone(final Context contexto, final String idContato) {
        ContentResolver cr = contexto.getContentResolver();
        Cursor phones = cr.query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + idContato, null, null);
        String numero = "";
        while (phones.moveToNext()) {
            numero = phones.getString(phones.getColumnIndex(Phone.NUMBER));
            break;
        }
        phones.close();
        return numero;
    }
}