Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update sms thread after inserting a draft in "content://sms/draft"
    primarykey
    data
    text
    <p>I am using the following code to insert a draft into content://sms/draft</p> <pre><code> ContentValues values = new ContentValues(); values.put("address", receiver2); values.put("body", body2); values.put("date", String.valueOf(System.currentTimeMillis())); values.put("type", "3"); values.put("thread_id", thread_id); getContentResolver().insert(Uri.parse("content://sms/draft"), values); </code></pre> <p>thread_id is 0 if there wasn't any conversation with the address above, else it's the id of that thread.</p> <p>When I run this code, the draft is indeed saved, but thread in the native sms client (stock android 4.0.3) isn't updated as "draft" [I can see the draft message body, but there is no "Draft" label on it. I have to open-close the thread, in order to be marked as marked]. I have read somewhere that there is an issue with the thread not updating properly. How can I force the threads to be updated so it shows ok in all the clients?</p> <p><strong>EDIT:</strong></p> <p>Having read your answers, I have updated my code a bit, but the problem remains. I have added a screenshot below, since when I wrote my question I was in a hurry and couldn't write it clearly enough.</p> <pre><code>protected void save_draft(String[] recipients, String body) { Uri threadIdUri = Uri.parse("content://mms-sms/threadID"); Uri.Builder builder = threadIdUri.buildUpon(); for (String recipient : recipients) { builder.appendQueryParameter("recipient", recipient); } Uri uri = builder.build(); Long thread_id = get_thread_id(uri); Log.d("thread_id", thread_id + " "); ContentValues values = new ContentValues(); values.put("body", body); values.put("date", String.valueOf(System.currentTimeMillis())); values.put("type", 3); values.put("thread_id", thread_id); getContentResolver().insert(Uri.parse("content://sms/draft"), values); //^tried "content://sms/" as well, but got the same result } private Long get_thread_id(Uri uri) { long threadId = 0; Cursor cursor = getContentResolver().query(uri, new String[] { "_id" }, null, null, null); if (cursor != null) { try { if (cursor.moveToFirst()) { threadId = cursor.getLong(0); } } finally { cursor.close(); } } return threadId; } </code></pre> <p><a href="http://oi46.tinypic.com/2mnkoqq.jpg" rel="nofollow noreferrer">a busy cat http://oi46.tinypic.com/2mnkoqq.jpg</a> As you can see, there is no "Draft" label, next to the draft I made via the code above.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload