I am trying to introduce SAF in my Android app.
It seems that the uris from many SAF methods are in encoded form, with characters like : or / being replaced by %3A and %2F, for example.
In my app I am decoding uris so they have this form:
content://com.android.providers.downloads.documents/tree/raw:/storage/emulated/0/Download/foldername
to store them.
Maybe it is wrong. So I ask whether SAF methods are tricked when passed uri that are parsed from strings in the form my app archives them, that is, with real characters like : and /
A method like this:
static public DocumentFile createFolderInFolder(Activity activity,String parentFolderUriStringParam,String folderName)
{
DocumentFile result=null;
String parentFolderUriString=Uri.decode(parentFolderUriStringParam);
ContentResolver contentResolver;
contentResolver = activity.getContentResolver();
Uri parentFolderUri=null;
Uri oldParentUri = Uri.parse(parentFolderUriString);
String id = DocumentsContract.getTreeDocumentId(oldParentUri );
parentFolderUri= DocumentsContract.buildChildDocumentsUriUsingTree(oldParentUri , id);
DocumentFile parentFolder = DocumentFile.fromTreeUri(activity, parentFolderUri);
result=parentFolder.createDirectory(folderName);
return result;
}
it has
parentFolderUriStringParam=content://com.android.providers.downloads.documents/tree/raw:/storage/emulated/0/Download/foldername
oldParentUri="content://com.android.providers.downloads.documents/tree/raw:/storage/emulated/0/Download/foldername"
id="raw:"
parentFolderUri=content://com.android.providers.downloads.documents/tree/raw%3A/document/raw%3A/children