2016-04-01 6 views

答えて

0

1.初めて連絡先を読むときに、財産を減らすことができます。

2.プロパティのタイプを読み込むときに、カーソルを使用できます。

private static final String[] CONTACTOR_ION = new String[]{ 
ContactsContract.CommonDataKinds.Phone.CONTACT_ID, 
ContactsContract.Contacts.DISPLAY_NAME, 
ContactsContract.CommonDataKinds.Phone.NUMBER 
}; 


Cursor phones = null; 
ContentResolver cr = getContentResolver(); 
try { 
phones = cr 
     .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI 
       , CONTACTOR_ION, null, null, "sort_key"); 

if (phones != null) { 
    final int contactIdIndex = phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID); 
    final int displayNameIndex = phones.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); 
    final int phoneIndex = phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); 
    String phoneString, displayNameString, contactIdString; 
    while (phones.moveToNext()) { 
     phoneString = phones.getString(phoneIndex); 
     displayNameString = phones.getString(displayNameIndex); 
     contactIdString = phones.getString(contactIdIndex); 
    } 
} 
      } catch (Exception e) { 
Log.e(TAG, e.getMessage()); 
} finally { 
if (phones != null) 
    phones.close(); 
} 
+0

linkManFormとは何ですか? –

+0

@SomeGuyああ、LinkManの情報を保存するためのオブジェクトです。コードを編集してこの行を削除します。 – Scavenger

関連する問題