連絡先の詳細を取得するために、次のコードを記述しました。問題は、私が取得している電話番号がnullを示していることです。手伝って頂けますか?
private void displayRecords() {
// An array specifying which columns to return.
String columns[] = new String[] { People.NAME, People.NUMBER_KEY};
Uri mContacts = People.CONTENT_URI;
Cursor cur = managedQuery(mContacts, columns, // Which columns to return
null, // WHERE clause; which rows to return(all rows)
null, // WHERE clause selection arguments (none)
null // Order-by clause (ascending by name)
);
if (cur.moveToFirst()) {
String name = null;
String phoneNo = null ;
do {
// Get the field values
name = cur.getString(cur.getColumnIndex(People.NAME));
phoneNo =cur.getString(cur.getColumnIndex(People.NUMBER_KEY));
Toast.makeText(this, name + " " + phoneNo, Toast.LENGTH_LONG).show();
} while (cur.moveToNext());
}
}