Wednesday, April 17, 2013


Tasker to mark unwanted or irrelevant unread sms as read and auto delete sms message via sqlite command

 

 

hi, I have been searching for a solution in the Internet regarding this issue. I believe sl4a script is able to work, however it is sort of difficult for me to study on it.

 

finally I found sqlite command is much better than that.

 

You see? simply use 'update' command, we may modify the SMS States as read in sms sqlite database.

 

-------First of all, you should root your phone first, or else, run shell action would not work properly.

 

 

Sqlite knowledge:

 

Okay, before we move onto tasker work, i wanna explain some specific knowledge regarding sqlite for you guys.

 

For sqlite command, “update” means edit and replace something with something. There is a fomular like below.

 

And for some fuzzy match keyword, you will have to use the command “like” and includes the wildcard “%” right after the keyword.

 

e.g.  update target catalog set column id=’new value’ where column id=’value’ and column id like ’keyward%’;

 

KKKKK denotes the particular keyward in the sms message body, remember there is ; in the end

 

And according to android sms sqlite database analysis, we will see “address” denotes incoming/outgoing phone number, and “read” denote the status of being read or unread. 0 means it is unread, 0 means it is already read. Body denotes to the sms message body.

 

So that is why we have to set the script like that. To change the read status from 0 into 1 within the sqlite database.

 

-------Most of stock ROM, the sms message database is located in data/dtata/com.android.providers.telephony/databases/mmssms.db

 

If you would not find the sms database in that folder, please search and modify the path accordingly.

 

 

------There is a thing, this action only affect the android sms database, but it doesn’t affect the ongoing notification, so after action took effect, the unread sms notification alert would not dismiss from the status bar. When you tap into the sms builtin apps, you will the sms has already been marked as read.




Okay, now let us get into the real matter on tasker.

 

 

*Auto mark unread specific sms as read*

 

Step 1: you should make sure sqlite3 system file is installed in your phone system, or else, the script would not work. You may go search in the play store to find a software named sqlite installer root (required root access), which would help you get the proper sqlite file installed in your system.

 

------(Tips: if you run the sqlite script and get the error code like “sqlite file not found” or “bad command” something, that means your phone system lib doesn’t have the proper sqlite 3 file.)

Android 4.0 earlier,  hit this link: http://bit.ly/sqlite3

Android 4.1+, please hit this linkhttp://bit.ly/sqlite3-for-jb

 

Step 2: create a foler named “sql” , and then create a txt file in that foler. Afterwards, copy the script below paste in the txt file. After done, rename the txt file into unreadsms.sql, which is with .sql as the postfix.

 

update sms set read='1' where address='XXXXXXX' and body like 'YYYYYYY%';

 

------XXXXXX denotes the receiver phone number which you would like to mark it as read, YYYYY is the particular keyword which to identify the specific SMS you would like to make it as read.

 

Step 3: Well, now you may just set up the action part like below in tasker or test it via Gscript to see if it works. (you may search and find out Gscript in play store. A very useful software to run shell command.)

 

Action: script-run shell-command: sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db < /sdcard/sql/unreadsms.sql

Check “Use Root” 

 

 

 

*Auto delete unwanted specific sms *

 

Step 1: make sure sqlite file is well installed in your phone system.

 

Step 2: create a foler named “sql” if you don’t have, and then create a new txt file in that foler. Afterwards, copy the script below paste in the txt file. After done, rename the txt file into delsms.sql, which is with .sql as the postfix.

 

delete from sms where address='XXXX' and body like 'YYYYY%';

 

(please refer to the above-mentioned sqlite knowledge to see more details)

 

Step 3: Well, now you may just set up the action part like below in tasker or test it via Gscript to see if it works.

 

Action: script-run shell-command: sqlite3 /data/data/com.android.providers.telephony/databases/mmssms.db < /sdcard/sql/delsms.sql

Check “Use Root” 

7 comments:

  1. How can I delete unread sms icon on taskbar, afer using this script?

    ReplyDelete
  2. Some messages I have are sms with an occasional mms in the same thread. This process cleared all of the sms' out but left the mms' behind. I tried adding a line and changing sms to mms but it failed saying there was no such entry.

    How would I adapt this to delete mms as well?

    ReplyDelete
    Replies
    1. Hi,

      is the mms you mentioned has a different phone number to the sms?

      i think it is possible, to make it done, you will need to look into your message database via sqlite editor tool to see the particular form name and column name, etc.

      then revise it as appropriate referring to this post or my another post done this via python script.

      Cathy

      Delete
  3. Hi,

    Could we please get a step-by-step guide on how to delete an sms containing a keyword from ANY number. I'm not clued up with sqlite. I just want something I can implement from a guidfe and make it work, please...

    Regards,
    B

    ReplyDelete
  4. PS:

    Would the following command work for the word "Opt"?

    delete from sms where body like 'Opt%';

    ReplyDelete