mediastore

How to rename a file in Android knowing only its media content Uri

孤人 提交于 2021-02-18 21:00:43
问题 In Android Q the MediaStore.Files.FileColumns.DATA field has been deprecated, and may be null or apps may not have the rights to read it, therefore is there a way to rename the filename section (not the path) of a file using only its media content Uri? Until now the DATA field could be used to find the real path of a file from a known Uri, but since it has been deprecated then the idea is not to even try to find or resolve the real file path, and use only its content Uri. Consider that the

Showing Folder with Video File in RecyclerView

*爱你&永不变心* 提交于 2021-02-18 12:20:14
问题 I am listing all my media files in a recycler view. Suppose a media file is in a folder, then I want to show that folder in my recycler view too. Here is my code to list media files var projection = arrayOf(MediaStore.Video.Media.DISPLAY_NAME) var cursor = CursorLoader(applicationContext, MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null).loadInBackground() if (cursor != null) { while (cursor.moveToNext()) { val name = cursor.getString(cursor.getColumnIndex(MediaStore

Showing Folder with Video File in RecyclerView

房东的猫 提交于 2021-02-18 12:20:10
问题 I am listing all my media files in a recycler view. Suppose a media file is in a folder, then I want to show that folder in my recycler view too. Here is my code to list media files var projection = arrayOf(MediaStore.Video.Media.DISPLAY_NAME) var cursor = CursorLoader(applicationContext, MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null).loadInBackground() if (cursor != null) { while (cursor.moveToNext()) { val name = cursor.getString(cursor.getColumnIndex(MediaStore

Is MediaStore.MediaColumns#DATE_TAKEN only available from API level 29?

好久不见. 提交于 2021-02-10 04:56:16
问题 I am trying to use MediaStore.Images.Media.DATE_TAKEN and getting warning from Android Studio IDE that it requires API 29 (Android Q). The official Google documentation here says this was Added in API level 29. Is this really true? I've checked the Google Sources from past releases all the way back until API 19 (KitKat) and I saw MediaStore.MediaColumns#DATE_TAKEN field being available since then. Why is the official documentation saying something different? Android 4.4 (KitKat) MediaStore

MediaRecorder Android 11 start failed -1004

我们两清 提交于 2021-02-08 15:18:36
问题 On Android 11 my MediaRecorder fails to initialize. I suspect the problem is related to scopedstorage, but I have been unable to figure out the cause. I am using MediaRecorder to record audio from the microphone. I extract the amplitude from the audio, so I have no intention to keep the file, that is why the path is /dev/null var mRecorder: MediaRecorder? = null if (mRecorder == null) { mRecorder = MediaRecorder() mRecorder!!.setAudioSource(MediaRecorder.AudioSource.MIC) mRecorder!!

How to retrieve a single media file from external storage using Mediastore?

巧了我就是萌 提交于 2021-01-29 08:10:14
问题 Before API 29, we could have easily retrieved a media file from external storage using these lines of code. val dirName = Environment.getExternalStorageDirectory().absolutePath + "/$appName/" val fileName = "$appName_$timeStamp.$extension" val dir = File(dirName) val file = File(dir, fileName) But I was unable to find a code snippet which can achieve the same thing using Mediastore API. Since getExternalStorageDirectory is deprecated in API 29, I don't know how to do. I have searched about

How to get an image's orientation information in android 10?

两盒软妹~` 提交于 2021-01-04 09:21:32
问题 Since android 10 there is some changes in accessing media files. After going through documentation https://developer.android.com/training/data-storage/shared/media i have been able to load the media content in to a bitmap, but i didn't get the orientation information. I know there is some restriction to the location information of the image, but does these exif restrictions also effect orientation information? If there is any other way to get an image's orientation information, please let me