I simply want to backup SMS messages and call log of my own android, programmatically (I want to integrate this as part of a larger backup script). There is a user app called "SMS Backup and Restore" which is able to do this. (How can I make an app run from the usb interface?)
When I try,
adb shell sqlite > dump
I get permission denied
. Every other attempt to read the database to access these logs, which I understand is in
data/data/com.sec.android.provider.logsprovider/databases/logs.db
is met with permission denied
.
What I read is that the only way to address this permission issue is to root the device, which I do not want to do at the moment.
Is there a way to do this through adb? I don't mind eventually writing an app if I have to, but I want to know if there is a simpler way.
You have to be rooted to access the /data/data directory. Without root, you could write a program to iterate through the MMS-SMS content provider and dump the results into your own database (that you can export/do whatever you want with).
Example of such:
try{
Uri uri = Uri.parse("content://sms");
ContentResolver contentResolver = getContentResolver();
Cursor SMSL = contentResolver.query(uri, null, null, null, "date asc");
while (SMSL.moveToNext()) {
long dateTimeMillis = SMSL.getLong(SMSL.getColumnIndex("date"));
Integer id1 = SMSL.getInt(SMSL.getColumnIndex("_id"));
String body = SMSL.getString(SMSL.getColumnIndex("body"));
Integer type1 = SMSL.getInt(SMSL.getColumnIndex("type"));
String address = SMSL.getString(SMSL.getColumnIndex("address"));
String read = SMSL.getString(SMSL.getColumnIndex("read"));
String seen = SMSL.getString(SMSL.getColumnIndex("seen"));
//Do whatever with the data here
SMSL.close();
}
} catch (Exception e){
e.printStackTrace();
}