2010-12-10 4 views
0

Ich versuche, dieseAndroid lesen Kontakte Anzahl

Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, 
      null, null, null); 
    Cursor cursor1 = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, 
      null, null, null); 

    int nameIdx = cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME); 
    int phoneIdx = cursor1.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER); 

    if (cursor.moveToFirst()) 
     do { 
      // Extract the name. 
      String name = cursor.getString(nameIdx); 
      // Extract the phone number. 
      String phone = cursor.getString(phoneIdx); 
      Log.i("ContentProvider", name); 
      Log.i("ContentProvider", phone); 
     } while (cursor.moveToNext()); 

ich in der Lage bin zu lesen Namen, aber Zahlen Ich erhalte einen Fehler

alt text

Antwort