in my application i create a temporary file this way
File tmp = File.createTempFile("TEST_", null, getFilesDir());
this resolves in a file that toURI()zed corrisponds to something like
/data/data/it.lorenzoff.test/files/TEST_XXX.tmp
In certain circumstances, i’d like to move this file permanently on sdcard but this code
dest = new File("/sdcard/permanentFile");
tmp.renameTo(dest);
never works.
I’m already using these permissions
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
but renameTo continue returning false.
What i’m doing wrong?
Thanks in advance
L.
The explanation can be found in documentation for
File:Many failures are possible. Some of the more likely failures include:
In this case source and target file paths point to different mount points (these two mount points even have different file system). You only option is to manually copy the file to sdcard and then delete the file from internal storage.