Is it possible to save sms in drafts using Android sdk

I am very new to Android development. I need some clarification from you. My question is: "Is it possible to programmatically save the SMS number in the program?". Please help me.

Thank you, Sehar Betalam.

+3
source share
2 answers

Yes, you can save the message as a draft, the code for 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!

+7
source

Do you mean that you are creating an SMS application and want to save draft messages? This is 100% your problem. You are absolutely free to save drafts as you want. There is virtually no Android support for text messaging other than providing an intent containing text and sending the text to you.

+1

Source: https://habr.com/ru/post/1783383/


All Articles