Hello everybody,

I am facing a problem when I am trying to access the Starred contacts.
Please help me in solving the problem.

*This Code is not Showing any exception*
When I am running the following code for on my android device the code is
working fine for the contacts i.e.,

   - The contacts that are manually added and
   - The contacts that are not manually added, but got added into my
   Contacts database due to *Syn <http://www.google.com/sync/android.html> *
   settings.

Thus, the ArrayList starListIds and starListIds are getting initialized
successfully, with the appropriate values.

*

**** Extracting and Storing the Starred Contacts into the lists
named starListIds and starListNames  BEGIN  ***/

*

*

ArrayList<String> starListNames = new ArrayList<String>();

*

*ArrayList<String> starListIds = new ArrayList<String>();*

*
   Cursor c = getContentResolver().query(Contacts.CONTENT_URI, null,
Contacts.STARRED + "=?", new String[] { "1" }, null);

 while (c.moveToNext()) {

StarListIds.add(c.getString(c.getColumnIndexOrThrow(RawContacts._ID)));
Log.i("Star-List", starListIds.get(blackListIds.size() - 1));
 name = c.getString(c.getColumnIndexOrThrow(Contacts.DISPLAY_NAME));
Log.i("Star-List", name);
 starListNames.add(name);

 }

*

*Exception is thrown only for the contacts that got into the database via.,
 Sync 
Contacts<http://googlemobile.blogspot.com/2008/10/google-on-android-gmail-and-contacts.html>
 settings.*
But, when I am trying to retrieve the Contacts using the Ids, present in the
ArrayList, starListIds,

   - *The exception is thrown, only for the Ids, that correspond to the
   Contacts that got added into the Contacts database via
Sync<http://googlemobile.blogspot.com/2008/10/google-on-android-gmail-and-contacts.html>
   *.

*05-14 20:47:41.337: ERROR/AndroidRuntime(32719): FATAL EXCEPTION: main*

*05-14 20:47:41.337: ERROR/AndroidRuntime(32719):
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a
size of 0*


   - *The Exception is not appearing for the contacts that are manually
   added into the database.*

 */**** Extracting the contact whose RawContacts._ID, is stored in the
array-list starListIds at a given position  ***/
*

*int position=2;*
*Cursor c1 = getContentResolver().query(*

*
 ContactsContract.CommonDataKinds.Phone.CONTENT_URI,*
* null,*
* ContactsContract.Data.RAW_CONTACT_ID + "=?"*
* + " AND "*
* + ContactsContract.Data.MIMETYPE + "='"*
* + Phone.CONTENT_ITEM_TYPE + "'",*
* new String[] { starListIds.get( position ) },*
* null); *

 *String id1=c1.getString(c1.getColumnIndex(Data.RAW_CONTACT_ID)); *

*
**
*

*
*
*
*

Regards,
Bikkanati Prabhakar.
E-Mail: [email protected]
Blog:    http://LetsXploreIT.blogspot.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to