I am using the following code,

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


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

  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);

 }

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

 /**** The above block of code is working fine, in both emulator and Android
Phone(LG P500)  ****/


*/**** 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));


 *Whats the Problem ?*
*In the above code, the id1 is not getting initialized in all cases.*
*e.g.,*

 *the id1 is getting initialized for the contacts that are manually added,
and popping a message of "Force Close" for the contacts that got
synchronized via., my gmail account.*
05-14 20:47:41.327: WARN/dalvikvm(32719): threadid=1: thread exiting with
uncaught exception (group=0x40020ac0)
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
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.database.CursorWrapper.getString(CursorWrapper.java:135)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
com.ProtoType.ViewBlackList$1$1.onClick(ViewBlackList.java:111)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.os.Handler.dispatchMessage(Handler.java:99)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.os.Looper.loop(Looper.java:123)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
android.app.ActivityThread.main(ActivityThread.java:4627)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
java.lang.reflect.Method.invokeNative(Native Method)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
java.lang.reflect.Method.invoke(Method.java:521)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
05-14 20:47:41.337: ERROR/AndroidRuntime(32719):     at
dalvik.system.NativeStart.main(Native Method)
05-14 20:47:41.457: WARN/ActivityManager(1363):   Force finishing activity
com.ProtoType/.ViewBlackList


-- 



Regards,
Bikkanati Prabhakar.
E-Mail: prabhakar.9...@gmail.com
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to