I want the user to select source folder and destination folder/destination cloud drive. So using SAF, i allow user to pick source folder and get its Uri as
content://com.android.externalstorage.documents/tree/primary%3ADownload/document/primary%3ADownload
This Uri was saved in Sharedpreference for later use. Similarly user selected Destination Folder Uri as below
content://com.android.externalstorage.documents/tree/primary%3ATest/document/primary%3ATest
This is how i saved Uri in SP
editor.putString("source", documentFile.getUri().toString()).apply();
Now i want all files will be moved from source to destination folder whenever user click on button.
//Getting Uri saved from SP
DocumentFile documentFile = DocumentFile.fromTreeUri(getApplicationContext(), Uri.parse(sharedPreferences.getString("source", "")));
DocumentFile[] df = documentFile.listFiles();
Log.i(TAG, df.length + "");
for (DocumentFile f : df) {
Log.i(TAG, "File path " + f.getUri().getPath());
try {
} catch (IOException e) {
e.printStackTrace();
}
}
Am i working in right direction as i m stuck here with do not know how to write code for copying files.