storage-access-framework

Android: Open file with intent chooser from URI obtained by Storage Access Framework

强颜欢笑 提交于 2019-11-29 03:37:48
In the beginning the user can select files with the new Storage Access Framework (Assuming the app is API>19): https://developer.android.com/guide/topics/providers/document-provider.html Then I save references to those chosen files by saving the URI`s which looks like: content://com.android.providers.downloads.documments/document/745 (in this case the file is from the default downloads dir`). Later, I want let the user to open those files (For example they names displayed in UI list, and the user selects one). I want to do this with the Android famous intent chooser feature, and all I have is

Get filepath from google drive in Lollipop (MediaStore.MediaColumns.DATA == null)

[亡魂溺海] 提交于 2019-11-28 11:32:03
When the user clicks the "send file" button in google drive and selects my app. I want to get the filepath of that file and then allow the user to upload it to a different location. I check these similar SO post for kitkat phones: Get real path from URI, Android KitKat new storage access framework Android - Convert URI to file path on lollipop However the solution to that no longer seems to work in Lollipop devices. The problem seems to be that MediaStore.MediaColumns.DATA returns null when running a query on the ContentResolver. https://code.google.com/p/android/issues/detail?id=63651 You

Storage Access Framework - failing to obtain document tree from uri (returned from Drive app)

荒凉一梦 提交于 2019-11-28 02:25:28
My Android app wants to create a folder in Google Drive and get the uri from the Drive app on the device. It sends an intent, you can see the code below: private void createFolder(String folderName) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); // Create a file with the requested MIME type. intent.setType("vnd.android.document/directory"); intent.putExtra(Intent.EXTRA_TITLE, folderName); startActivityForResult(intent, WRITE_REQUEST_CODE); } then it gets the returned data, you can see the code below: @Override protected void

Android: Open file with intent chooser from URI obtained by Storage Access Framework

不打扰是莪最后的温柔 提交于 2019-11-27 17:41:12
问题 In the beginning the user can select files with the new Storage Access Framework (Assuming the app is API>19): https://developer.android.com/guide/topics/providers/document-provider.html Then I save references to those chosen files by saving the URI`s which looks like: content://com.android.providers.downloads.documments/document/745 (in this case the file is from the default downloads dir`). Later, I want let the user to open those files (For example they names displayed in UI list, and the

Open a Google Drive File Content URI after using KitKat Storage Access Framework

我与影子孤独终老i 提交于 2019-11-27 17:32:23
I am using the Storage Access Framework for android 4.4 and opening the file picker. Everything works except when choosing a file from Google Drive, I can only figure out how to open it as an input stream, but I would like to get a java File object. The content uri that's being returned looks something like this: content://com.google.android.apps.docs.storage/document/acc%3D4%3Bdoc%3D2279 Other questions that are similar but do not have a working solution which allows me to get the filename, filesize and contents: Get real path from URI, Android KitKat new storage access framework Android

How to get free and total size of each StorageVolume?

≯℡__Kan透↙ 提交于 2019-11-27 15:53:35
问题 Background Google (sadly) plans to ruin storage permission so that apps won't be able to access the file system using the standard File API (and file-paths). Many are against it as it changes the way apps can access the storage and in many ways it's a restricted and limited API. As a result, we will need to use SAF (storage access framework) entirely on some future Android version (on Android Q we can, at least temporarily, use a flag to use the normal storage permission), if we wish to deal

Storage Access Framework - failing to obtain document tree from uri (returned from Drive app)

﹥>﹥吖頭↗ 提交于 2019-11-27 04:56:41
问题 My Android app wants to create a folder in Google Drive and get the uri from the Drive app on the device. It sends an intent, you can see the code below: private void createFolder(String folderName) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); // Create a file with the requested MIME type. intent.setType("vnd.android.document/directory"); intent.putExtra(Intent.EXTRA_TITLE, folderName); startActivityForResult(intent, WRITE_REQUEST

Android SD Card Write Permission using SAF (Storage Access Framework)

微笑、不失礼 提交于 2019-11-27 00:51:45
After a lot of findings about how to write(and rename) a file in SD Card (android 5 and above), I think the new SAF provided by android will be required to take permission from user to write SD card file. I have seen in this File Manger Application ES File Explorer that initially it takes read and write permission the following way as shown in pictures. After selecting sd card, the write permission is granted. So in the same way I tried to use SAF, but failed in renaming a file. My code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Open a Google Drive File Content URI after using KitKat Storage Access Framework

﹥>﹥吖頭↗ 提交于 2019-11-26 19:03:16
问题 I am using the Storage Access Framework for android 4.4 and opening the file picker. Everything works except when choosing a file from Google Drive, I can only figure out how to open it as an input stream, but I would like to get a java File object. The content uri that's being returned looks something like this: content://com.google.android.apps.docs.storage/document/acc%3D4%3Bdoc%3D2279 Other questions that are similar but do not have a working solution which allows me to get the filename,

How to persist permission in android API 19 (KitKat)?

我们两清 提交于 2019-11-26 09:29:09
问题 In my application I store the path of image in my SQlite db for further use. The path that I get is content://com.android.providers.media.documents/document/image%3A71964 When I retrieve this path from the database and try to retrieve the image from that path android throws java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{42c84ec8 23911:com.gots.gb/u0a248} (pid=23911, uid=10248) requires android.permission