The return value of update query is 0

2019-07-10 07:12发布

问题:

I want to marks a sms as read . I have id of that sms . I have tried the following code to mark this sms as read .

public void setRead(int position, String smsMessageId) {

        ContentValues values = new ContentValues();
        values.put("read",true);
        int flag = context.getContentResolver().update(Uri.parse("content://sms/inbox"),
                values, "_id=" + smsMessageId, null);
        Toast.makeText(context, "The result is "+flag, Toast.LENGTH_LONG).show();  
}

But the return result is 0 . Why is the return result 0 ?

回答1:

My app is not set as default . That is why , the return result is 0 .If the app is set as default , then the return result is 1 .



标签: android sms