6

For some reason, NO sms app on android seem to offer the very basic feature (that even old dumb-phones have) of marking an SMS unread.

I am considerinng writing such an app myself, but before I begin I would like to know a little bit about how to do it and why it hasn't been done before. Surely it is not impossible?

pinkfloydhomer
  • 873
  • 3
  • 9
  • 16
  • 2
    here is your solution http://stackoverflow.com/questions/6059604/set-sms-as-read-in-android pass false or 0 as value of read. – Pankaj Kumar Jun 19 '12 at 11:50

3 Answers3

2

NOTE: Firstly, just to let you know in Android it is little typical to work with Messaging System in Android(2.3 or lower) as to work with things like SMS requires to query with Content Providers which is officially not available and also Android guys have warned about it. You can check about it in the below URL: http://android-developers.blogspot.in/2010/05/be-careful-with-content-providers.html

Further for your solution and just for everybody's concern would like to divide my explanation according to Android OS versions:

- Version 2.3 or lower: Yes application is as simple to make as guided by Pankaj Kumar and it will work for the above mentioned Android OS version and lower.

- Version 4.0 & up: Application will fail and not work. Yes, as warned by Android Dev Guys, from this version and up, you will not be able to read Messaging contents as I have tried it so your application will not work on coming Android releases. You can only get the numbers of them like: inbox, sent, outbox failed etc... but you cannot modify or read contents.

- Version > 3.0 & < 4.0 : Never tested and tried.

Hope this information helps you and saves your time for going on a dead end route :)))

Community
  • 1
  • 1
abhy
  • 933
  • 9
  • 13
  • So maybe this is why no app exists in Play Store that can mark an sms as unread? I find it ridiculous that such a basic feature is missing and seemingly impossible to implement in android. – pinkfloydhomer Jun 19 '12 at 14:18
  • Yes, the reason is very much that only. About your missing feature question earlier version supported Messaging Content Providers but later it was pulled out due to security/privacy and also for safe side so as the application doesn't breaks when the Vendor modifies OS and its Messaging system according to its need. – abhy Jun 20 '12 at 08:00
  • @pinkfloydhomer This said, if the actual *use* of such a marking is just not to forget to answer the message later (which I guess is the most common use case for this feature), would it be not easy to add an extra tag at the application level ? Like a simple `do-not-let-me-drawn-in-your-archives` tag? – iago-lito Sep 10 '16 at 06:37
1

Here you go

SMS Database has following Columns

06-19 17:41:19.723: V/vipul(25223): _id
06-19 17:41:19.723: V/vipul(25223): thread_id
06-19 17:41:19.723: V/vipul(25223): address
06-19 17:41:19.723: V/vipul(25223): person
06-19 17:41:19.723: V/vipul(25223): date
06-19 17:41:19.723: V/vipul(25223): protocol
06-19 17:41:19.723: V/vipul(25223): read
06-19 17:41:19.723: V/vipul(25223): status
06-19 17:41:19.723: V/vipul(25223): type
06-19 17:41:19.723: V/vipul(25223): reply_path_present
06-19 17:41:19.723: V/vipul(25223): subject
06-19 17:41:19.723: V/vipul(25223): body
06-19 17:41:19.723: V/vipul(25223): service_center
06-19 17:41:19.723: V/vipul(25223): locked
06-19 17:41:19.723: V/vipul(25223): error_code
06-19 17:41:19.723: V/vipul(25223): seen
06-19 17:41:19.723: V/vipul(25223): deletable
06-19 17:41:19.723: V/vipul(25223): hidden
06-19 17:41:19.723: V/vipul(25223): group_id
06-19 17:41:19.723: V/vipul(25223): group_type
06-19 17:41:19.723: V/vipul(25223): delivery_date
06-19 17:41:19.723: V/vipul(25223): date_sent

Below snippet marks all SMS as Unread you can chnage it to match the id and only make unread that SMS

package org.vipul;

import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

public class SMSSampleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Uri uri = Uri.parse("content://sms/inbox");
        Cursor cursor = managedQuery(uri, null, null, null, null);

        for (int i = 0; i < cursor.getColumnCount(); i++) {
            Log.i("vipul", cursor.getColumnName(i));
        }

        if (cursor.moveToFirst()) {
            do {

                String id = cursor.getString(0);

                ContentValues contentValues = new ContentValues();
                contentValues.put("read", false);
                getContentResolver().update(uri, contentValues, "_id=?",
                        new String[] { id });
                contentValues.clear();
            } while (cursor.moveToNext());

        }
    }
}

Finally add android.permission.READ_SMS ans android.permission.WRITE_SMS in manifest

Vipul
  • 27,808
  • 7
  • 60
  • 75
0

There is an app called "Mark as Unread", published by Christian Asbjørn Skogsberg (check for it) so i guess it is possible.

JesusS
  • 1,645
  • 1
  • 18
  • 31
  • Yes, but this app has been removed. It worked on 2.x, although it was less elegant than having the feature integrated into the sms app itself. – pinkfloydhomer Jun 19 '12 at 11:42