Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to save sms in drafts using Android sdk

I am very new to Android development. I need some clarifications from you. My question is 'Is it possible to store no.of sms's in drafter programatically?". Please help me.

Thank you, Sekhar Bethalam.

like image 489
sek Avatar asked Dec 14 '25 10:12

sek


2 Answers

Yes, you can save a message as a draft, the code to do this is below:

//Store the message in the draft folder so that it shows in Messaging apps.
ContentValues values = new ContentValues();
// Message address.
values.put("address", address); 
// Message body.
values.put("body", messagebody);
// Date of the draft message.
values.put("date", String.valueOf(System.currentTimeMillis())); 
values.put("type", "3");
// Put the actual thread id here. 0 if there is no thread yet.
values.put("thread_id", "0"); 
getContentResolver().insert(Uri.parse("content://sms/draft"), values);

Happy coding!

like image 94
Camille Sévigny Avatar answered Dec 16 '25 23:12

Camille Sévigny


Do you mean you're making an SMS app and you want to save message drafts? That is 100% your problem. You are totally free to save drafts however you want. There is practically no Android assistance to texting beyond delivering the intent that contains the text and sending the text out for you.

like image 39
Falmarri Avatar answered Dec 16 '25 23:12

Falmarri