I saw in a lot of places that it\'s a problem to copy the SharedPreferences file to the sd card because every manufacturer place it somewhere else.
I want to backup
File ff = new File("/data/data/"
+ MainActivity.this.getPackageName()
+ "/shared_prefs/pref file name.xml");
Log.i("ffffdffffdffffdffffdd", ff.getPath() + "");
copyFile(ff.getPath().toString(), sdcard path/save file name.xml");
private void copyFile(String filepath, String storefilepath) {
try {
File f1 = new File(filepath);
File f2 = new File(storefilepath);
InputStream in = new FileInputStream(f1);
OutputStream out = new FileOutputStream(f2);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
System.out.println("File copied.");
} catch (FileNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
}
}