【发布时间】:2017-01-26 02:54:10
【问题描述】:
我以前从未遇到过这个错误,所以我不确定该怎么做或这意味着什么
未处理的异常类型
OperationApplicationException
出现在这段代码中:
public void putSettings(SharedPreferences pref){
ArrayList<ContentProviderOperation> ops =
new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
.withSelection(Data.RAW_CONTACT_ID + "=?", new String[]{String.valueOf(pref.getString(SmsPrefs.ID, ""))})
.withValue(Data.MIMETYPE,"vnd.android.cursor.item/color")
.withValue("data1",nColor).build());
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); //error
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
.withSelection(Data.RAW_CONTACT_ID + "=?", new String[]{String.valueOf(pref.getString(SmsPrefs.ID, ""))})
.withValue(Data.MIMETYPE,"vnd.android.cursor.item/vibrate")
.withValue("data1", nVibrate).build());
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); //error
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
.withSelection(Data.RAW_CONTACT_ID + "=?", new String[]{String.valueOf(pref.getString(SmsPrefs.ID, ""))})
.withValue(Data.MIMETYPE, "vnd.android.cursor.item/sound")
.withValue("data1", ringTonePath).build());
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);//error
}
它给了我 2 个选项“添加抛出声明”和“用 try/catch 包围”。
我必须做什么以及为什么?
【问题讨论】:
-
这是在哪一行抛出的?你违反了接触操作的限制。
标签: java android unhandled-exception