в моем приложении я пытаюсь получить контакты для телефонной книги. кажется, что запрос не возвращает никакого результата, хотя у меня есть контакты, хранящиеся на эмуляторе. я использовал следующий код:
Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
people.moveToFirst();
while(people.moveToNext()) {
int nameFieldColumnIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String contact = people.getString(nameFieldColumnIndex);
int numberFieldColumnIndex = people.getColumnIndex(PhoneLookup.NUMBER);
String number = people.getString(numberFieldColumnIndex);
Toast.makeText(this, ""+contact+""+number, Toast.LENGTH_LONG);
}
people.close();
журнал ошибок
E/AndroidRuntime( 277): FATAL EXCEPTION: main
E/AndroidRuntime( 277): java.lang.RuntimeException: Unable to start service mobile_security.mobile_security.ui.getSimCardContacts@44ef8960 with Intent { cmp=mobile_security.mobile_security.ui/.getSimCardContacts }: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
E/AndroidRuntime( 277): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3063)
E/AndroidRuntime( 277): at android.app.ActivityThread.access$3600(ActivityThread.java:125)
E/AndroidRuntime( 277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2096)
E/AndroidRuntime( 277): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 277): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 277): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 277): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 277): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 277): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 277): Caused by: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
E/AndroidRuntime( 277): at android.database.CursorWindow.getString_native(Native Method)
E/AndroidRuntime( 277): at android.database.CursorWindow.getString(CursorWindow.java:329)
E/AndroidRuntime( 277): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
E/AndroidRuntime( 277): at android.database.CursorWrapper.getString(CursorWrapper.java:135)
E/AndroidRuntime( 277): at mobile_security.mobile_security.ui.getSimCardContacts.onStart(getSimCardContacts.java:40)
E/AndroidRuntime( 277): at android.app.Service.onStartCommand(Service.java:420)
E/AndroidRuntime( 277): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3053)
E/AndroidRuntime( 277): ... 10 more
Я не знаю, как с этим справиться. может кто-нибудь помочь. ТНХ