Trying to read a Contact


Last Updated:

  1. ROHara

    ROHara New Member This Topic's Starter

    Joined:
    Oct 30, 2008
    Messages:
    2
    Likes Received:
    0
    I am trying to read from (and eventually write to) the Contacts database. Here is a code fragment:

    String[] projection = new String[]
    { People._ID, People.NAME, People.NUMBER};
    Uri contacts = Uri.parse("content://contacts/people");
    Cursor mCursor = managedQuery(contacts, projection,
    null, null, null);

    In the emulator, this code fragment dies on the managedQuery call with this error:

    java.io.IOException: An established connection was aborted by the software in your host machine

    Adding the READ_CONTACTS permission has no effect. I am at a loss at how to debug this.

    Does anyone out there see where I am going astray?

    Thanks, Bob
     

    Advertisement
  2. ROHara

    ROHara New Member This Topic's Starter

    Joined:
    Oct 30, 2008
    Messages:
    2
    Likes Received:
    0
    I will answer my own question. It is necessary to go to the AndroidManifest and set uses-permissions to READ_CONTACTS. Then it all works, just like a real computer.
     

Share This Page

Loading...