Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Contact to SIM from Android

I have an issue while I try to copy a contact which exists in the android contacts application to the SIM card. Following is the code:

ContentValues cv = new ContentValues();
cv.put("tag", cName);
cv.put("number", cNumber);

Uri uri = context.getContentResolver().insert(SIM_CONTENT_URI, cv);
Log.d(TAG_LOG, "URI is : " + uri);

I have values inside cName and cNumber variables. But when I print the log to see the value of the uri variable: it is null.

Can anyone please let me know if I have gone wrong somewhere in the code above for inserting to SIM?

like image 516
user264953 Avatar asked Jun 08 '11 05:06

user264953


1 Answers

I just have implemented a simple code to insert contact in SIM card, maybe it can help you:

private void insertSIMContact(String number, String name) {
     Uri simUri = Uri.parse("content://icc/adn");
     ContentValues values = new ContentValues();
     values.put("number", number);
     values.put("tag", name);
     getContentResolver().insert(simUri, values);
}
like image 120
Nguyen Avatar answered Oct 31 '22 18:10

Nguyen