mediastore

Can't update MediaStore on Android 10

给你一囗甜甜゛ 提交于 2020-05-13 04:57:10
问题 I've been updating meta data in the MediaStore through a ContentResolver, but this no longer works with Android Q (API 29). The following code gives me a warning, and the description is not updated: ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.DESCRIPTION, "Some text"); int res = getContext().getContentResolver().update( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values, MediaStore.Images.Media._ID + "= ?", new String[]{sImageId}); android.process.media W

Access and share file under Picture folder in Internal/External Storage Android Q

时间秒杀一切 提交于 2020-04-17 22:18:09
问题 Many breaking changes happen in Android Q when it comes to storage management and one of my feature in the app is to allow user to take a shot in a View like CardView item, create a Bitmap of it and save that to mass storage of the device. Once saving is done it will then trigger an Intent.ACTION_SEND so user can share the recently save image with some description to social apps and compose a email with GMail. This code snippet works fine. try { //Get primary storage status String state =

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

MediaStore.Images.Media.insertImage deprecated

☆樱花仙子☆ 提交于 2020-03-18 06:46:18
问题 I used to save images using MediaStore.Images.Media.insertImage but insertImage method is now deprecated. The docs say: This method was deprecated in API level 29. inserting of images should be performed using MediaColumns#IS_PENDING, which offers richer control over lifecycle. I don't really get it, since MediaColumns.IS_PENDING is just a flag, how am I supposed to use it? Should I use ContentValues ? 回答1: SOLVED The code suggested from @CommonsWare has no problem, except the fact that if

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

Create/Copy File in Android Q using MediaStore

自古美人都是妖i 提交于 2020-02-06 07:31:11
问题 I am trying to find method which can handle create and copy of any file except Media files (Picture/Video/Audio) to copy from one place to other in internal storage in Android Q. In this I have my file created in my app folder and I want those to move to Download Folder or some directory which I can create in Internal storage and then move their. I searched and found modified below code but missing some thing to make it workable. Can some one help. ContentResolver contentResolver =

How to set MediaStore openOutputStream offset in Long?

你。 提交于 2020-02-05 04:01:07
问题 I am trying to download a file to download the directory in Android 10 and above. I did as following. val resolver = contentResolver val contentValues = ContentValues().apply { put(MediaStore.MediaColumns.DISPLAY_NAME, "CuteKitten001") put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg") put(MediaStore.MediaColumns.RELATIVE_PATH, "Download/PerracoLabs") } val uri = resolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues) val outputStream: OutputStream? = if (uri == null) null

How can I get MediaMetaData like Album, Track, Titel, Albumart, etc. from MediaStore in Android 10

此生再无相见时 提交于 2020-01-25 10:14:06
问题 I struggled for a long time to fetch album, track, duration, album art from audiofiles using Android 10 mediaStore . What I did so far: Open an Intent an fetch the Audio-Folder: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); startActivityForResult(Intent.createChooser(intent, "Choose directory"), PICK_AUDIO_REQUEST); Then