0

Hello
I would like to move a file from cache directory to downloads. I have searched several hours for a solution but verified solutions which supposed to work also for me, unfortunately they did not. I have several files in cache and can read them without any problems. When trying copy them to download directory the action is working and I can see the file in adb shell but not on the device.

I do request permission from user using:

private static String[] PERMISSIONS_STORAGE = { android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE };

ActivityCompat.requestPermissions(getActivity(), PERMISSIONS_STORAGE, 1);

Download directory on the device
Download directory on adb shell

My last try looks like this:

File source = new File(this.activity.getCacheDir(), "/" + item.getTitle());
File dest = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "/" + item.getTitle());
FileUtils.copy(new FileInputStream(source), dest);

AndroidManifest.xml contains also this lines:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Any help will be more then appreciate. Thanks!

0 Answers0