Hello.

I am trying to read and write contacts on the SIM phonebook.

First I tried writing a contact, with GetContentResolver.insert(),
passing RawContacts.CONTENT_URI as URI and ensuring the column
RawContacts.ACCOUNT_NAME had the value "SIM", and adding 2 lines (1 for
name and 1 for phone) to Data.CONTENT_URI, linked by contact ID. This
seemed to work: the contacts showed in the contact list with the SIM
logo next to them, but they wouldn't survive a reboot... apparently
that's just a placeholder in memory, which is synced with the real SIM
at startup and at every change.

Then I tried reading the list of contacs on the SIM with

                Cursor cur = getContentResolver().query(
                                Uri.parse("content://icc/adn")
                                ,null
                                ,null
                                ,null
                                ,null
                                );

This fails with a NullPointerException on a real phone. On the emulator, it 
returns a Cursor with 0 lines (likely, as I haven't added any contact).
Strangely, accessing content://icc/fdn and content://icc/sdn both work, both on 
emulator and on phone.

Finally, I tried writing a contact with

                ContentValues values = new ContentValues();
                values.put("name","Name Of Contact");
                values.put("number", "+777777777");
                Uri uri = getContentResolver().insert(
                                Uri.parse("content://icc/adn")
                            , values)
                            ;

This returns a null URI and no contact is inserted.

What's wrong there, and what's the right way of doing this?

Regards,
Fabrizio


--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to