navid abutorab navid abutorab - 1 year ago 156
Android Question

android -how to save sent messages sent via SmsMessage

I'm using SmsMessage to send sms via my application . this is my code :

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(tel, null, text, null, null);

it works fine and I've no problem with sending messages. the only issue is that I want to save sent sms in android message inbox.

How can I do so ?

Answer Source

Sms content provider can help you to write data into message inbox:

    ContentValues values = new ContentValues();
    values.put("address", tel);
    values.put("body", text);
    values.put("date", "135123000000");
    getContentResolver().insert(Uri.parse("content://sms/sent"), values);

Permission required:

 <uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download