【问题标题】:Authority for Batch update the sms content批量更新短信内容的权限
【发布时间】:2015-09-03 08:30:00
【问题描述】:

我想通过applyBatch 方法更新短信正文。我想知道我应该在下面的代码中使用哪个AUTHORITY。我如何使用applyBatch() 短信的第一个参数?

Uri mSmsinboxQueryUri = Uri.parse("content://sms");

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    Set<String> keys = map.keySet();
    String where = "_id = ?";

    for(String k : keys) {
        String body = map.get(k);
        ops.add(
                ContentProviderOperation.newUpdate(mSmsinboxQueryUri).withSelection(where, new String[]{k})
                        .withValue(Telephony.Sms.BODY, body)
                        .withYieldAllowed(true)
                        .build());
    }

    try {
        getContentResolver().
                applyBatch(ContactsContract.AUTHORITY, ops);
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (OperationApplicationException e) {
        e.printStackTrace();
    }

【问题讨论】:

    标签: android android-contentresolver


    【解决方案1】:

    根据this发帖是"sms"

    在这个link的android源代码中也定义了这样的权限

    private static final String AUTHORITY = "mms-sms";

    所以你的操作应该是:

    getContentResolver().applyBatch("sms",ops); // if it throws exception use "mms-sms" 
    

    对我来说很好。

    【讨论】:

      猜你喜欢
      • 2018-10-08
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 2010-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多