In my previous post you can find how to read incoming SMS content programmatically.
In this post I will give you information about how to read outgoing SMS content. It's same as incoming SMS data reading, just need use different URI to read outgoing SMS content.
To read outgoing SMS content first add user permission:
<uses-permission android:name="android.permission.READ_SMS"/>
Then call below method :
public StringBuffer getOutgoingSMSContent() {
ContentResolver contentResolver = getContentResolver();
Uri uri = Uri.parse("content://sms/sent/");
StringBuffer messagedata = new StringBuffer();
int count = 0;
Cursor cursor = contentResolver.query(uri, null, null, null, null);
if (cursor.getCount() != 0) {
if (cursor.moveToFirst()) {
do {
messagedata.append("Outgoing message count: " + (count +1) + "\n");
for (int m = 0; m < cursor.getColumnCount(); m++) {
if (cursor.getColumnName(m).equalsIgnoreCase("address")
|| cursor.getColumnName(m).equalsIgnoreCase("date")
|| cursor.getColumnName(m).equalsIgnoreCase("body")
|| cursor.getColumnName(m).equalsIgnoreCase("type"))
{
messagedata.append(cursor.getColumnName(m) + " : "
+ cursor.getString(m));
messagedata.append("\n");
}
}
messagedata.append("\n");
count++;
} while (cursor.moveToNext());
}
}
cursor.close();
cursor = null;
return messagedata;
}
This method will return list of all outgoing SMS content.
Result will look something like this :
Here 'address' is mobile number of receiver.
'date' is message sent time in milliseconds.
'type' is message type incoming/outgoing. 2 is outgoing message type.
'body' is message text.
In this post I will give you information about how to read outgoing SMS content. It's same as incoming SMS data reading, just need use different URI to read outgoing SMS content.
To read outgoing SMS content first add user permission:
<uses-permission android:name="android.permission.READ_SMS"/>
Then call below method :
public StringBuffer getOutgoingSMSContent() {
ContentResolver contentResolver = getContentResolver();
Uri uri = Uri.parse("content://sms/sent/");
StringBuffer messagedata = new StringBuffer();
int count = 0;
Cursor cursor = contentResolver.query(uri, null, null, null, null);
if (cursor.getCount() != 0) {
if (cursor.moveToFirst()) {
do {
messagedata.append("Outgoing message count: " + (count +1) + "\n");
for (int m = 0; m < cursor.getColumnCount(); m++) {
if (cursor.getColumnName(m).equalsIgnoreCase("address")
|| cursor.getColumnName(m).equalsIgnoreCase("date")
|| cursor.getColumnName(m).equalsIgnoreCase("body")
|| cursor.getColumnName(m).equalsIgnoreCase("type"))
{
messagedata.append(cursor.getColumnName(m) + " : "
+ cursor.getString(m));
messagedata.append("\n");
}
}
messagedata.append("\n");
count++;
} while (cursor.moveToNext());
}
}
cursor.close();
cursor = null;
return messagedata;
}
This method will return list of all outgoing SMS content.
Result will look something like this :
Here 'address' is mobile number of receiver.
'date' is message sent time in milliseconds.
'type' is message type incoming/outgoing. 2 is outgoing message type.
'body' is message text.