scoped-storage

Android Studio MediaStore, below SDK 29 save image in sd card fails

吃可爱长大的小学妹 提交于 2020-06-17 09:31:46
问题 I need to save image in sd_card's pictures directory below Android 10.I have implemented scoped storage & This code works in sdk 29 & above, because MediaStore.getExternalVolumeNames was added in sdk 29. Below sdk 29 how to get getContentUri of sd_card . val values = ContentValues().apply { put(MediaStore.Images.Media.DISPLAY_NAME, destinationFileName) put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg") put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + File

Android Studio MediaStore, below SDK 29 save image in sd card fails

≯℡__Kan透↙ 提交于 2020-06-17 09:31:21
问题 I need to save image in sd_card's pictures directory below Android 10.I have implemented scoped storage & This code works in sdk 29 & above, because MediaStore.getExternalVolumeNames was added in sdk 29. Below sdk 29 how to get getContentUri of sd_card . val values = ContentValues().apply { put(MediaStore.Images.Media.DISPLAY_NAME, destinationFileName) put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg") put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + File

Android 10: How to delete MediaStore item and it's associated data on file system programmatically?

时光怂恿深爱的人放手 提交于 2020-04-16 02:59:04
问题 I am updating my app to use Scoped Storage feature introduced in Android 10. My app works with MediaStore and displays images, videos and audio files and provides ability for user to delete item. What I did earlier to delete file: Got path from MediaStore.MediaColumns.DATA Used new File(path).delete() to delete that file Manually updating MediaStore Now that MediaStore.MediaColumns.DATA is not available I migrated to deleting items from MediaStore using ContentResolver.delete() For example I

Android Q (10) ask permission to get access all storage. Scoped storage

不打扰是莪最后的温柔 提交于 2020-03-21 16:21:10
问题 In Android 10 apps that need to access storage need to ask permission to concrete path. But apps like file explorer can ask permission for root storage and gain permission to read/write all storage. That is what I am trying. According to Android we must use "ACTION_OPEN_DOCUMENT_TREE" for this. The problem I have is that everything seems correct, but the permission is finally not granted to the app. private void askAndroid10Perm() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)

Android Q (10) ask permission to get access all storage. Scoped storage

核能气质少年 提交于 2020-03-21 16:20:51
问题 In Android 10 apps that need to access storage need to ask permission to concrete path. But apps like file explorer can ask permission for root storage and gain permission to read/write all storage. That is what I am trying. According to Android we must use "ACTION_OPEN_DOCUMENT_TREE" for this. The problem I have is that everything seems correct, but the permission is finally not granted to the app. private void askAndroid10Perm() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)

Writing files to publicly accessible documents folder in Android Q - Scoped Storage

霸气de小男生 提交于 2020-03-14 02:57:30
问题 Background After migrating to Android Q I can no longer find a suitable way to gain write access to the documents folder ( /storage/emulated/0/Documents ) And before anyone mentions the many other questions on scoped storage I've read through many of them and from what I've seen so far all of the solutions use a app specific directory or accessing a media directory only (not documents folder access). From what I understand in Android Q I can either choose: Use a app specific directory that is

Writing files to publicly accessible documents folder in Android Q - Scoped Storage

久未见 提交于 2020-03-14 02:57:13
问题 Background After migrating to Android Q I can no longer find a suitable way to gain write access to the documents folder ( /storage/emulated/0/Documents ) And before anyone mentions the many other questions on scoped storage I've read through many of them and from what I've seen so far all of the solutions use a app specific directory or accessing a media directory only (not documents folder access). From what I understand in Android Q I can either choose: Use a app specific directory that is

Writing files to publicly accessible documents folder in Android Q - Scoped Storage

淺唱寂寞╮ 提交于 2020-03-14 02:57:03
问题 Background After migrating to Android Q I can no longer find a suitable way to gain write access to the documents folder ( /storage/emulated/0/Documents ) And before anyone mentions the many other questions on scoped storage I've read through many of them and from what I've seen so far all of the solutions use a app specific directory or accessing a media directory only (not documents folder access). From what I understand in Android Q I can either choose: Use a app specific directory that is

Test programmatically if in Android 10+ the legacy external storage access is disabled

。_饼干妹妹 提交于 2020-02-20 07:12:48
问题 Is there a simple API call that would tell me if an app running on Android 10 or later must use Scoped Storage access, that is, if the normal file access, a.k.a. "Legacy External Storage" is disabled? Note that even if the app in AndroidManifest.xml, section declared: android:requestLegacyExternalStorage="true" the file access may still be denied due to Google policy changes in the future, so testing this value is useless. The only way I found is to test if the external storage root directory

Android Q: Get image from gallery and process it

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 03:53:19
问题 I know it seems like a very basic question, but it's specifically for Android Q. I just want to get an image from Gallery and compress it and send to the server. But because of the Android Q's Scoped Storage, it's harder than I thought. I'll first explain what I did with code: First I send out the intent to pick the image. fun openGallery(fragment: Fragment){ val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) intent.type = "*/*" val mimeTypes = arrayOf(