storage-access-framework

How does SAF (storage access framework) recognize your USB-stick?

自闭症网瘾萝莉.ら 提交于 2019-12-12 01:14:19
问题 Using Android 6.0.1, API 23, How do you get a USB-stick connected to your Android-phone being visible in the SAF picker that displays all matching document providers (including your USB-stick) ?? Moreover how to set-up SAF in order to create files and folders on the USB portable-storage ?? From the SAF-documentation, I tried: public void performFileSearch() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); // in my case, showing only text

SAF - File written in parent folder, not in the right path

ぃ、小莉子 提交于 2019-12-11 14:30:04
问题 My app wants to copy a file from a private app folder to a SAF folder that was created inside an user-selected SAF folder. Folder creation is Ok. The copy method is: public static boolean copyFileToTargetSAFFolder(Context context, String filePath, String targetFolder, String destFileName ) { Uri uri = Uri.parse(targetFolder); String docId = DocumentsContract.getTreeDocumentId(uri); Log.d("target folder uri",uri.toString()); Log.d("target folder id",docId); Uri dirUri = DocumentsContract

Open specific path using Storage access framework

爱⌒轻易说出口 提交于 2019-12-11 08:03:53
问题 I am able to write the text files by opening the Files app using the intent. But when I open the Files app through intent it is opening Downloads path instead I would like to open a specific path . Is that possible ? Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TITLE, fileName); startActivityForResult(intent, CREATE_REQUEST_CODE); I would like to launch the Files app using

How do you unzip a file with Storage Volume (/StorageAccessFramework)?

旧城冷巷雨未停 提交于 2019-12-11 06:03:57
问题 I'm using this code (Android 7.0/Nougat) to unpack a zip file in external storage (including multiple folder levels inside): try { ZipFile zip = new ZipFile(zippath); Enumeration enu = zip.entries(); while(enu.hasMoreElements()) { ZipEntry zipEntry = (ZipEntry) enu.nextElement(); BufferedInputStream bis = null; String fileName = null; try { fileName = zipEntry.getName(); fileName = fileName.replace("\\",File.separator).replace("/",File.separator); int p = fileName.lastIndexOf(File.separator);

Open Specific Directory Using Storage Access Framework

时光怂恿深爱的人放手 提交于 2019-12-10 12:55:11
问题 I'm currently able to obtain a file URI by opening the Lollipop file picker using the code below: Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivity(intent); The file picker opens either at the root of Internal Storage or the last directory that I opened. How can I make the file picker show the contents of a specific directory? For example, I might want the file picker to show the contents of the Download folder after launching like in the picture

Storage Access Framework persist permissions not working

南楼画角 提交于 2019-12-10 12:50:22
问题 I use Android Storage Access Framework to access some files on SD card. It is important for me to persists this permissions, to be able to edit files after reboot of device. So according to Storage Access Framework documentation I use Persist permissions that gives the user continued access to the files through your app, even if the device has been restarted. However, after some time I noticed that for some users permissions were somehow revoked. Because when I am trying to use SAF for

Saving an image after getting folder from Storage Access Framework UI

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 19:31:28
I set a preference for users to select save folder for my app using Storage Access Framework. After getting uri onActivityResult I save it to SharedPreferences as String and save image when it's to be saved. I'm using this method to save image successfully. public void saveImageWithDocumentFile(String uriString, String mimeType, String name) { isImageSaved = false; try { Uri uri = Uri.parse(uriString); DocumentFile pickedDir = DocumentFile.fromTreeUri(this, uri); DocumentFile file = pickedDir.createFile(mimeType, name); OutputStream out = getContentResolver().openOutputStream(file.getUri());

Passing a native fd int to FFMPEG from openable URI

与世无争的帅哥 提交于 2019-12-08 19:16:13
问题 I am trying to open a file descriptor from a CATEGORY_OPENABLE URI from the Storage Access Framework. I am first trying with a file on the sdcard, which I can already resolve to a file path using the _data column and open (I am trying to get away from doing this, and use the file descriptor instead). I get the the native int fd like this: int fd = getContentResolver().openFileDescriptor(data.getData(), "r").detachFd(); Then in C++, I am trying to open it like this, the idea taken from How to

Writing EXIF data to image saved with DocumentFile class

与世无争的帅哥 提交于 2019-12-08 01:52:58
问题 I need to get a File from DocumentFile or Uri with correct scheme not the one with content://com.android.externalstorage.documents/tree/primary: if the device's main memory is selected. To get File or absolute path of the image i need the one with file:///storage/emulated/0 or storage/emulated/0 but i could not find a way to get correct Uri for building a File to write EXIF data to image. My scenario is: User chooses a path to save images which returns Uri with content://com.android

Writing EXIF data to image saved with DocumentFile class

只愿长相守 提交于 2019-12-06 07:27:25
I need to get a File from DocumentFile or Uri with correct scheme not the one with content://com.android.externalstorage.documents/tree/primary: if the device's main memory is selected. To get File or absolute path of the image i need the one with file:///storage/emulated/0 or storage/emulated/0 but i could not find a way to get correct Uri for building a File to write EXIF data to image. My scenario is: User chooses a path to save images which returns Uri with content://com.android.externalstorage.documents onActivityResult(). I save this path with treeUri.toString() to SharedPreferences for