1. Download our Official Android App: Forums for Android!

Apps Issue while access contacts of android

Discussion in 'Android Development' started by rishabh, Sep 22, 2009.

  1. rishabh

    rishabh Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Sep 22, 2009

    Sep 22, 2009
    1
    0
    5
    Hi to all,
    I am new for android development. I am trying read and write contacts to android addressbook.
    I tried following line of code for write name into android

    public class SecondApp extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ContentValues values = new ContentValues();
    values.put(Contacts.People.NAME, "Rishabh");
    ContentResolver cr = getContentResolver();
    Uri uri = cr.insert(People.CONTENT_URI, values);

    but i am getting "The application has stopped unexpectedly. Please try again" message.

    what is wrong in it ?
    How can i access contacts of android ?

    Thanks in advance...
     

    Advertisement

Share This Page

Loading...