android - How to update list item in listview? -
i have listview
smsarrayadapter
of smsitem objects.
smsarrayadapter.java
public class smsarrayadapter extends arrayadapter<smsitem>
i want update item of listview
. why taking smsitem objects in onitemclick
method , trying mark them read.
smsitem smsmessagestr = (smsitem) arrayadapter.getitem(pos); if (smsmessagestr.status == false) { ((smsarrayadapter) arrayadapter).setread(pos, smsmessagestr.id); toast.maketext(this, "id " + smsmessagestr.id, toast.length_long).show(); arrayadapter.notifydatasetchanged(); }
the method marking sms read follows declared in smsarrayadapter.java
public void setread(int position, string smsmessageid) { smsbody.get(position).status = true; smsitem smsitem = smsbody.get(position); smsitem.status = true; smsbody.set(position, smsitem); 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 "+flag, toast.length_long).show(); }
the sms not marking read. problem ?
Comments
Post a Comment