0
我無法從getContentResolver中刪除對話,我不知道在哪個部分做錯誤,因爲我也搜索了這些,但不能幫助自己,我也嘗試了不同的解決方案,這是在stackoverflow上給出的,但同樣的結果&非常感謝。無法從getContentResolver()中刪除刪除
下面是代碼:
public static boolean deleteSmsofContact(Context context, String number,
boolean deleteLocked)
{
int result;
if (deleteLocked) {
//changes values
String[] selectionArgs=new String[]{number};
String selection= ""+"address=?";
//
result = context.getContentResolver().delete(Uri.parse("content://sms/"),selection,selectionArgs);
// Log.d("UF","WOW "+result+" " +number);
} else {
result = context.getContentResolver().delete(Constants.URI_SMS,
"address=? AND locked=?", new String[] { number, "1" });
}
if (result > 0) {
return true;
}
return false;
}
這是從我打電話的方法:
boolean result = Utils.deleteSmsofContact(InboxActivity.this, sms.getNumber(), true);
if (result) {
dataList.remove(threadPosition);
iAdapter.notifyDataSetChanged();
Toast.makeText(InboxActivity.this,"Removed",Toast.LENGTH_LONG).show();
}else
{
Toast.makeText(InboxActivity.this,"cant removed",Toast.LENGTH_LONG).show();
}