Skip to content Skip to sidebar Skip to footer

Android: How To Access The Sim Contact Table Using The Sdk?

I am trying to use this query to read the contacts on the SIM. cur = managedQuery(Uri.parse('content://icc/adn') ,null ,null

Solution 1:

i have used the following code to get the simcard details..It works fine

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

         while (cursorSim.moveToNext()) {           
             listName.          add(cursorSim.getString(cursorSim.getColumnIndex("name")));
             listContactId.     add(cursorSim.getString(cursorSim.getColumnIndex("_id")));      
             listMobileNo.      add(cursorSim.getString(cursorSim.getColumnIndex("number")));
            }

Here the name, _id, number are column names from the simcard table

Solution 2:

i got it,

StringsimUrl="content://icc/adn";
Intentintent=newIntent();
            Log.d(TAG, "simUrl=" + simUrl);
            intent.setData(Uri.parse(simUrl));
            Uriuri= intent.getData();
            CursormCursor= context.getContentResolver().query(uri, null,
                    null, null, null);

and then, for(...){...}, you know

Solution 3:

I just implemented a small piece of code that used to display a list of contacts in SIM card. Hope that it can help you

privatevoiddisplaySIMContacts() {
    try {
        StringsimPhoneId=null;
        StringsimPhoneNum=null;
        StringsimPhoneName=null;

        UrisimUri= Uri.parse("content://icc/adn");
        CursorsimCursor= getContentResolver().query(simUri, null, null, null, null);

        while(simCursor.moveToNext()) {
            simPhoneId = simCursor.getString(simCursor.getColumnIndex("_id"));
            simPhoneNum = simCursor.getString(simCursor.getColumnIndex("name"));
            simPhoneName = simCursor.getString(simCursor.getColumnIndex("number"));
            Log.v("!!!", " id = " + simPhoneId + " - name = " + simPhoneName
                + " - number = " +simPhoneNum);
        }
    }
    catch (Exception e) {
       e.printStackTrace();
    }
}

Post a Comment for "Android: How To Access The Sim Contact Table Using The Sdk?"