I have rooted phone.
I want to copy data/data/com.android.providers.telephony/databases/mmssms.db
file to sd card programatically.
I am getting error like
java.io.FileNotFoundException: /data/data/com.android.providers.telephony/databases/mmssms.db (Permission denied)
Please help me….
Thanking you in advance…
I am using below code to copy database in sd card
‘
try {
File sd = Environment.getExternalStorageDirectory();
String path = Environment.getDataDirectory().getAbsolutePath();
File data = Environment.getDataDirectory();
String currentDBPath = "/data/com.android.providers.telephony/databases/mmssms.db";
String backupDBPath = "/bkup/mmssms.db";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
// Local database
InputStream input = new FileInputStream(currentDB);
// Path to the external backup
OutputStream output = new FileOutputStream(backupDB);
// transfer bytes from the Input File to the Output File
byte[] buffer = new byte[1024];
int length;
while ((length = input.read(buffer))>0) {
output.write(buffer, 0, length);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(this, e.getMessage().toString(), Toast.LENGTH_LONG).show();
}`
You’re trying to copy the database from other application. It’s not allowed. Even your phone is rooted, your application is not granted the root permission yet.
You need to grant the root permission first, and use the shell commands to copy file, like this (cp /data/…./xxx.db /sdcard/xxx.db)
Read command output inside su process
Just use the method in this post and change the shell command to …