1
new contact
を追加してsave to sim
のオプションを選択すると、RawContacts
とContacts
テーブルにも連絡先が保存されますか?また、電話で連絡先をすべて表示するときは、contact application
からsimまたはsimの連絡先が連絡先テーブルに保存され、連絡先アプリケーションにsim連絡先が表示されます。Androidで新しい連絡先を追加する
new contact
を追加してsave to sim
のオプションを選択すると、RawContacts
とContacts
テーブルにも連絡先が保存されますか?また、電話で連絡先をすべて表示するときは、contact application
からsimまたはsimの連絡先が連絡先テーブルに保存され、連絡先アプリケーションにsim連絡先が表示されます。Androidで新しい連絡先を追加する
try{
// add a row to the RawContacts table
ContentValues values = new ContentValues();
values.put(RawContacts.ACCOUNT_TYPE, "com.anddroid.contacts.sim");
values.put(RawContacts.ACCOUNT_NAME, "SIM");
Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
// get the ID of the newly-added line
long rawContactId = ContentUris.parseId(rawContactUri);
// add a "name" line to the Data table, linking it to the new RawContact
// with the CONTACT_ID column
values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
values.put(StructuredName.DISPLAY_NAME, "Name");
cr.insert(Data.CONTENT_URI, values);
// this insert succeeds
// add a "phone" line to the Data table, linking it to the new RawContact
// with the CONTACT_ID column
values.clear();
values.put(Data.CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
values.put(Phone.NUMBER, "+12345678901");
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
cr.insert(Data.CONTENT_URI, values);
// this insert fails with a NullPointerException
}
catch(Exception e){
String xx=e.toString();
System.out.println(xx);
}