我想问一下 
      android 2.1之后 如何新增,更新,删除 sim卡中联系人。这个问题在网上搜索了很久,也没有找到具体的解决方法。
请大家帮忙,看看谁知道如何处理?
     权限应该是没有问题的,    
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />uri也应该是正确的,使用
         Uri uri = Uri.parse("content://icc/adn");   
           String[] projection = new String[] { "id","name", "number" };   
           
           mCursor = managedQuery(uri, projection, null, null,   
            null);
可以查询出sim卡中的已有联系人,但是就是不知道该如何实现 新增,更新,删除等功能。

解决方案 »

  1.   

    java层只能读取这个provider,其他的方法全是抽象的没有实现
      

  2.   

    这个应该是有实现的。
    Uri uri = Uri.parse("content://icc/adn"); 
    ContentValues values= new ContentValues();
    values.put("tag", "lktest");
    values.put("number", "222");
    Uri cccd = getContentResolver().insert(uri ,values);
    使用上面的代码,是可以插入的,但是只能在每次重新开机之后,新增一条记录,之后就不起作用了。
    我是在 三星 i5700上面测试的。大家可以看看各自的手机是否也是这个现象。有没有人实现过这个功能?或者可以提供相应的参考文档?既然可以插入一次,那么我觉得就是该方法在使用上面有某些限制,但是实在是不知道是什么限制,盼望高手指教:)
      

  3.   

    修改freamwork的ICCprovider这个类,实现修改 删除既可!
      

  4.   

    可以新增多条,删除也可以。 但是如果只要更新一次就不可以了,需要重新启动手机才能再次新增,删除。 我是在三星 GT-I5508上面调试的。
      

  5.   

    发现ICCPROVIDER只能删除,写入SIM卡的记录,貌似USIM卡就没反应了
      

  6.   

    额,这些好像都是我之前的工作内容,如果需要我可以提供整个2.1上的修改代码
    包括增加,删除,修改
    支持sim卡,USIM卡
    支持中文等等。。
      

  7.   

    帖一段:
    public Uri insert(Uri url, ContentValues initialValues) {
            Uri resultUri;
            int efType;
            String pin2 = null;        if (DBG) log("insert");        int match = URL_MATCHER.match(url);
            switch (match) {
                case ADN:
                    efType = IccConstants.EF_ADN;
                    break;            case FDN:
                    efType = IccConstants.EF_FDN;
                    pin2 = initialValues.getAsString("pin2");
                    break;            default:
                    throw new UnsupportedOperationException(
                            "Cannot insert into URL: " + url);
            }        String tag = initialValues.getAsString("tag");
            String number = initialValues.getAsString("number");
            // TODO(): Read email instead of sending null.
            boolean success = addIccRecordToEf(efType, tag, number, null, pin2);        if (!success) {
                return null;
            }        StringBuilder buf = new StringBuilder("content://icc/");
            switch (match) {
                case ADN:
                    buf.append("adn/");
                    break;            case FDN:
                    buf.append("fdn/");
                    break;
            }        // TODO: we need to find out the rowId for the newly added record
            buf.append(0);        resultUri = Uri.parse(buf.toString());        /*
            // notify interested parties that an insertion happened
            getContext().getContentResolver().notifyInsert(
                    resultUri, rowID, null);
            */        return resultUri;
        }
      

  8.   

    中间层各个公司实现的不同,还要看具体的固件,这点不如nokia来的稳定,呵呵
      

  9.   

    1.6的时候做过这个,是能直接调到framework层的代码,进行短信同步(包括SIM卡,就是操作速度相当慢)操作。
      

  10.   

    请问10楼可以提供2.1上的修改代码么,如果可以的话请发送到[email protected],谢谢!!!
      

  11.   

    其实源码中已经有实现的类,Setting里面就有,这个问题纠结了我好长时间最后无意间发现
      

  12.   

    修改时可以实现的
    ContentValues values = new ContentValues();
    values.clear();
    values.put("tag", oldName);
    values.put("number", oldPhoneNumber);
    values.put("newTag", newName);
    values.put("newNumber", newPhoneNumber);
    long res = 0;
    Uri uri = Uri.parse("content://icc/adn");
    res = this.cr.update(uri, values, null, null);
    System.out.println("修改结果 ====== "+res);
    return res;过了那么长时间了,不知你的问题解决了没有,希望能帮到你
      

  13.   

    我就是用的这个方法,不过你的values.clear();这句为什么要加呢?我没加也可以修改啊