mediastore

java.lang.UnsupportedOperationException Albums cannot be directly modified

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-09 19:52:31
问题 How to update album metadata of audio file in Android Q media store? I tried the answer suggested, https://stackoverflow.com/a/60152702/4732846, it worked. But this works for individual tracks. If I use the same logic and form the uri for albums, val uri = ContentUris.withAppendedId(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, albumId) and try to edit. I get this exception. java.lang.UnsupportedOperationException Albums cannot be directly modified This is the closest link that I could find

API 29 Mediastore Access

醉酒当歌 提交于 2020-07-17 08:19:54
问题 My app creates playlists in the android mediastore. All is well for api's including 28 however, api 29 seems to require additional permissions. Inserting a new playlist name and id works without issue. When it comes to inserting track id and play order, an access permission exception is thrown. In verifying the Uri, i found that when resolver.insert for API 29 the exception error is: java.lang.SecurityException: myapp_name has no access to content://media/external_primary/audio/media/146 The

Download Large File with MediaStore Android 10

放肆的年华 提交于 2020-07-09 03:14:12
问题 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

Android 10: fetch the gallery via MediaStore with location information

二次信任 提交于 2020-07-04 13:50:30
问题 Looking at the storage access changes introduced in Android 10 here, location informations are now redacted by default. Google asks us to call setRequireOriginal() on the "MediaStore" object with the media's uri as a parameter. This works when you fetch medias one by one, but what about when we query the ContentResolver for the whole gallery? See this sample: String[] projection = { MediaStore.Files.FileColumns._ID, MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.MEDIA_TYPE,

Media scanner for secondary storage on Android Q

狂风中的少年 提交于 2020-07-04 06:45:29
问题 With the newer Android Q many things changed, especially with scoped storage and gradual deprecation of file:/// URIs. The problem is the lack of documentation on how to handle media files correctly on Android Q devices. I have a media file (audio) management application and I could not find yet a reliable way to tell to the OS that I performed a change to a file so that it can update its MediaStore record. Option #1: MediaScannerService MediaScannerConnection.scanFile(context, new String[]{

How to update metadata of audio file in Android Q media store?

情到浓时终转凉″ 提交于 2020-05-21 21:38:13
问题 Updating metadata of audio file in media store is not working in Android Q OS, it works in all other OS. I am using content provider with uri specified as MediaStore.Audio.Media.EXTERNAL_CONTENT_URI. It is working fine in all below Android Q device. Below is the code that I am using to update track metadata. ContentValues cv = new ContentValues(); ContentResolver resolver = getContentResolver(); Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; cv.put(MediaStore.Audio.Media.TITLE,

How to update metadata of audio file in Android Q media store?

白昼怎懂夜的黑 提交于 2020-05-21 21:35:28
问题 Updating metadata of audio file in media store is not working in Android Q OS, it works in all other OS. I am using content provider with uri specified as MediaStore.Audio.Media.EXTERNAL_CONTENT_URI. It is working fine in all below Android Q device. Below is the code that I am using to update track metadata. ContentValues cv = new ContentValues(); ContentResolver resolver = getContentResolver(); Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; cv.put(MediaStore.Audio.Media.TITLE,

Replacement for “GROUP BY” in ContentResolver query in Android Q ( Android 10, API 29 changes)

 ̄綄美尐妖づ 提交于 2020-05-16 03:59:46
问题 I'm upgrading some legacy to target Android Q, and of course this code stop working: String[] PROJECTION_BUCKET = {MediaStore.Images.ImageColumns.BUCKET_ID, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.DATA, "COUNT(" + MediaStore.Images.ImageColumns._ID + ") AS COUNT", MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.MediaColumns._ID}; String BUCKET_GROUP_BY = " 1) and " + BUCKET_WHERE.toString() + " GROUP BY

Can't update MediaStore on Android 10

六月ゝ 毕业季﹏ 提交于 2020-05-13 04:57:33
问题 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