1

I'm trying to read phone number from users profile information. This is the piece of code I have, but it doesn't return the phone number.

Cursor c = getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
    int count = c.getCount();
    String[] columnNames = c.getColumnNames();
    boolean b = c.moveToFirst();
    int position = c.getPosition();
    if (count == 1 && position == 0) {
        for (int j = 0; j < columnNames.length; j++) {
            String columnName = columnNames[j];
            String columnValue = c.getString(c.getColumnIndex(columnName));
        }
    }
    c.close();

I cannot relay on telephonyManager's getLine1Number(), since the number may not be available in the SIM, so I want to get it from users profile as a second option.

Edgar Zakaryan
  • 576
  • 5
  • 11

0 Answers0