Insert and delete SIM contacs working but it needs to be phone restart to update the changes
        Posted  
        
            by girishgm08
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by girishgm08
        
        
        
        Published on 2010-04-05T13:41:19Z
        Indexed on 
            2010/04/05
            13:43 UTC
        
        
        Read the original article
        Hit count: 321
        
android
Hi All,
I am able to insert the contacts into SIM card and delete from it. But it needs to be phone restart to update the changes.
The below is the code woks for delete the conatcs,
Uri simUri = Uri.parse("content://icc/adn"); Cursor cur = context.getContentResolver().query(simUri, null, null, null, null); prn("Number of SIM Contacts are.."+cur.getCount()); int row =0; while(cur.moveToNext()){ String name = cur.getString(cur.getColumnIndex("name")); prn("Name..."+name); String data = cur.getString(cur.getColumnIndex("number")); if(!data.equals("")) prn("Number.."+data); String where = null; if(!name.equals("") && !data.equals("")){ where = "tag =" + name + "AND" + "number =" +data; } else if(name.equals("") && !data.equals("")){ where = "number ="+data; } else { where = "tag ="+name+ "AND" +"number="+null; }
    context.getContentResolver().delete(simUri, where, null);
    row++;
   }
   prn(row+" are deleted");
   cur.close();
   cur = null;
Please look into this issue and give suggestions on this.
Thanks, Girish G M
© Stack Overflow or respective owner