I am working on android application (as a final year project in my university) which backup and restores contacts, messages, calendar, call logs etc. I started working on it yesterday and until now I am able to get the message conversations through ContentResolver like this:
private void MsgBackup(){
try {
Uri uri = Uri.parse("content://sms");
//Uri uri = Uri.parse("content://mms-sms/conversations/");
ContentResolver contentResolver = getContentResolver();
final String[] projection = new String[]{"*"};
Cursor SMSL = contentResolver.query(uri, projection, null, null, null);
int msgscount = SMSL.getCount();
msgs = new String[SMSL.getCount()][2];
int i = 0;
while (SMSL.moveToNext()) {
address = SMSL.getString(SMSL.getColumnIndex("address"));
body = SMSL.getString(SMSL.getColumnIndex("body"));
msgs[i][0] = address;
msgs[i][1] = body;
i++;
}
SMSL.close();
//will do something here to backups msgs array
}catch (Exception e){
e.printStackTrace();
Toast.makeText(getApplicationContext(),"Error Fetching messages, check permissions!",Toast.LENGTH_LONG).show();
}
}
What I am worried about is "Restoring them". I read somewhere that it is not possible to restore messages without root access. If so, then how come the applications in the market do this job without root access?