How to get All Sim Contacts in Android programmatically?

前端 未结 4 766
失恋的感觉
失恋的感觉 2021-01-20 19:28

How to list sim contacts in Android programmatically? I got the code to get phone contacts here but I need sim contacts too with this.

4条回答
  •  长发绾君心
    2021-01-20 20:01

    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")));
                }
    

    simply now following code to get the simcard details..It works fine

提交回复
热议问题