के आकार के साथ मेरे कोड नीचे हैं और मुझे android.database.CursorIndexOutOfBoundsException
मिला है: इंडेक्स -1 ने 2 त्रुटि के आकार के साथ अनुरोध किया है। क्या कोई मुझे बता सकता है कि इसे कैसे हल किया जाए?android.database.CursorIndexOutOfBoundsException: इंडेक्स -1 अनुरोध किया गया है, 2
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
if (Integer.parseInt(cur.getString(
cur.getColumnIndex(People.PRIMARY_PHONE_ID))) > 0) {
Cursor pCur = cr.query(
Contacts.Phones.CONTENT_URI,
null,
Contacts.Phones.PERSON_ID +" = ?",
new String[]{id}, null);
int i=0;
int pCount = pCur.getCount();
String[] phoneNum = new String[pCount];
String[] phoneType = new String[pCount];
while (pCur.moveToNext()) {
phoneNum[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.NUMBER));
phoneType[i] = pCur.getString(
pCur.getColumnIndex(Contacts.Phones.TYPE));
i++;
}
}
}
}
'फोन टाइप' क्या है। साथ ही, आपको अपना प्रश्न संपादित करने और अपने कोड को सही तरीके से प्रारूपित करने की आवश्यकता है। – Falmarri
यह त्रुटि हो सकती है bcoz आपने ur emulator में कोई संपर्क नहीं जोड़ा है .......... –
क्या आपने AndroidManifest में उचित अनुमतियां जोड़ दी हैं? – Sriram