Android: how to access the SIM contact table using the SDK?

后端 未结 3 1744
梦谈多话
梦谈多话 2020-12-18 06:04

I am trying to use this query to read the contacts on the SIM.

            cur = managedQuery(Uri.parse(\"content://icc/adn\")
                ,null
                 


        
3条回答
  •  被撕碎了的回忆
    2020-12-18 07:05

    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

    private void displaySIMContacts() {
        try {
            String simPhoneId = null;
            String simPhoneNum = null;
            String simPhoneName = null;
    
            Uri simUri = Uri.parse("content://icc/adn");
            Cursor simCursor = 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();
        }
    }
    

提交回复
热议问题