storage-access-framework

How to handle SAF when I can only handle File or file-path?

落花浮王杯 提交于 2021-02-19 02:43:06
问题 Background Up until Android Q, if we wanted to get information about an APK file, we could use WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE to get access to the storage, and then use PackageManager.getPackageArchiveInfo function on the file-path. Similar cases exist, such as using ZipFile class on a compressed file, and probably countless framework APIs and third party libraries. The problem Google announced a huge amount of restrictions recently on Android Q. One of them is called Scoped

Open res or assets folder with Intent.ACTION_PICK or Intent.ACTION_GET_CONTENT

天涯浪子 提交于 2021-02-11 14:15:01
问题 I want to start a file picker with Intent.ACTION_PICK or Intent.ACTION_GET_CONTENT . The user is supposed to be navigated directly to the apps resources folder or assets folder. Is this possible at all? Do I have to build my own filepicker? 来源: https://stackoverflow.com/questions/64634776/open-res-or-assets-folder-with-intent-action-pick-or-intent-action-get-content

How to hint content manager chooser to open directly on a selectable position with ACTION_OPEN_DOCUMENT_TREE

筅森魡賤 提交于 2021-02-10 21:20:41
问题 When you use ACTION_OPEN_DOCUMENT_TREE to pick the permission to a path where to store files in Android 11, the default Android content manager by default opens on a recently used path and the button "USE THIS FOLDER" for some reason doesn't even appear at all, even if this path is an accessible path, unless the user manually move through paths to go to a suitable position (or returns in the path opened by default moving through directories if this is a selectable position). E.g. Assume the

Writing many files on Android 11

自闭症网瘾萝莉.ら 提交于 2021-02-07 10:51:39
问题 Scenario I am trying to create many files, as a feature for the user. For example, I might write an app which creates one file for each song they listened to for the past few weeks (e.g. a text file with lyrics). I can't make the user pick the directory and filename for each file I generate, it would take them hours. The user should have access to these documents from other apps. Solutions (not really) In Android 11, it seems like Storage Access Framework is not going to be useful. I noticed

Android open InputStream from relative uri to ACTION_OPEN_DOCUMENT?

五迷三道 提交于 2021-01-29 06:21:34
问题 I'am trying to open multiple files relative to a json configuration file in android 4.4 (api level 19), I used Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType({mime}); this.startActivityForResult(intent, {code}); to let the user find te configuration file, and from there open multiple files that I know the path from the config file. But i get Caused by: java.lang.SecurityException: Permission Denial: reading com.android

Storage Access Framework doesn't show cloud roots when using ACTION_OPEN_DOCUMENT_TREE

那年仲夏 提交于 2021-01-28 07:43:01
问题 I read that I have to prepare my app in advance for Android Q release because then the common read/write access to files outside the app-owned directories could be deprecated, if they do not withdraw the new way of managing those files. I have not so many lines of codes to change, luckily. The fact is that the Storage Access Framework seems to have some issues. And it is here from Kitkat, I see (I did not know it). Otherwise my code is wrong. I am not able to simply make the user choose a

can't control the initial directory where the SAF UI should start

為{幸葍}努か 提交于 2021-01-07 06:34:40
问题 I'm trying to save a text file using SAF (Storage Access Framework) but I can't control where it should be saved, I used this method from the Documentation as follows: private void createFile(Uri pickerInitialUri) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/*"); intent.putExtra(Intent.EXTRA_TITLE, "new.txt"); // Optionally, specify a URI for the directory that should be opened in // the system file picker when

Unexpected behavior when DocumentFile.fromTreeUri() is called on Uri of subdirectory DocumentFile object

不想你离开。 提交于 2020-06-29 03:42:09
问题 If I call DocumentFile.fromTreeUri() on main directory and I list its content, it returns all DocumentFile object related to folders and files contained in the directory as expected, but when I try to call DocumentFile.fromTreeUri() on the Uri of one of the DocumentFile folders inside it, rather than returning all DocumentFile objects related to folders and files contained in the subdirectory as expected, it actually returns exactly the same content of the call on its root Uri E.g. I have a