Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid retrieve data from contact
    primarykey
    data
    text
    <p>i try to write application to read name, last name , and id of contact and show in listview, i use following code</p> <pre><code> Cursor cursor = getContentResolver().query( ContactsContract.Contacts.CONTENT_URI, null, null, null, null); SmsMultiCasting.selectedRow = new int[cursor.getCount()]; cursor.moveToFirst(); // data = new String[cursor.getCount()][12]; if (cursor.getCount() &gt; 0) { do { try { i++; Log.d("number", String.valueOf(i)); // numberPhone = 0; contactId = cursor .getString(cursor .getColumnIndex(ContactsContract.Contacts._ID)); Uri contactUri = ContentUris.withAppendedId( Contacts.CONTENT_URI, Long.parseLong(contactId)); Uri dataUri = Uri.withAppendedPath(contactUri, Contacts.Data.CONTENT_DIRECTORY); Cursor phones = getContentResolver() .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, null, null); int phonenumber = 0; while (phones.moveToNext()) { phonenumber++; } if (phonenumber &gt; 0) // phones.moveToNext(); { try { Cursor nameCursor = getContentResolver() .query(dataUri, null, Data.MIMETYPE + "=?", new String[] { StructuredName.CONTENT_ITEM_TYPE }, null); nameCursor.moveToFirst(); do { String firstName = nameCursor .getString(nameCursor .getColumnIndex(Data.DATA2)); String lastName = ""; String displayname = cursor .getString(cursor .getColumnIndex(Contacts.DISPLAY_NAME_ALTERNATIVE)); if (!firstName.equals(displayname)) { lastName = nameCursor .getString(nameCursor .getColumnIndex(Data.DATA3)); } if (firstName.equals(null) &amp;&amp; lastName.equals(null)) SmsMultiCasting.Arrayefullname .add("unknown name"); else if (firstName.equals(null)) SmsMultiCasting.Arrayefullname .add(lastName); else if (lastName.equals(null)) SmsMultiCasting.Arrayefullname .add(firstName); else SmsMultiCasting.Arrayefullname .add(firstName + " " + lastName); SmsMultiCasting.Arrayeid.add(String .valueOf(firstName + " " + lastName + "//" + contactId)); } while (nameCursor.moveToNext()); nameCursor.close(); } catch (Exception e) { } } } catch (Exception t) { } String image_uri = cursor .getString(cursor .getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI)); SmsMultiCasting.ArrayePhoto.add(image_uri); */ } while (cursor.moveToNext()); </code></pre> <p>but this code in large date gives error to me, how can i use lighter code to get data???</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload