Sunday, 15 March 2015

android - Delete all messages from number -



android - Delete all messages from number -

i want delete messages (in, out, draft, ....) number.

my code is:

public void deleteallmessages(string number) { cursor cursor = context.getcontentresolver().query(sms_uri_all, new string[] { "_id", "address" }, null, null, null); int x = 0; while (cursor.movetonext()) { int id = cursor.getint(0); string address = cursor.getstring(1); if (address.equals(number)) { int delete = context.getcontentresolver().delete(sms_uri_all, "_id=" + id, null); x++; } } log.i(getclass().getname(), "for:" + number + " delete msg: " + x); }

edit: seek

i seek `context.getcontentresolver().delete(uri.parse("content://sms/" + id), null, null);`

but same result...

the count of x right nil deleted! why? how can delete messages of number? version of android utilize 4.4.2 powered nexus 4.

i working on same project used abortbroadcast() did not delete sms stops broadcast receiver

uri urisms = uri.parse("content://sms/inbox"); cursor c = context.getcontentresolver().query( urisms, new string[] { "_id", "thread_id", "address", "person", "date", "body" }, "read=0", null, null); if (c != null && c.movetofirst()) { { long id = c.getlong(0); long threadid = c.getlong(1); string address = c.getstring(2); string body = c.getstring(5); string date = c.getstring(3); log.e("log>>>", "0>" + c.getstring(0) + " 1>" + c.getstring(1) + " 2>" + c.getstring(2) + " 3>" + c.getstring(3) + " 4>" + c.getstring(4) + " 5>" + c.getstring(5)); if (message.equals(body) && address.equals(number)) { this.abortbroadcast(); } } while (c.movetonext()); }

android messages

No comments:

Post a Comment