update filename in mediastore at Rename

This commit is contained in:
tibbi 2016-12-08 20:40:26 +01:00
parent 06e1796902
commit 31f42118bb

View file

@ -79,7 +79,8 @@ class RenameFileDialog(val activity: SimpleActivity, val file: File, val callbac
private fun sendSuccess(oldFile: File, newFile: File) {
val values = ContentValues()
values.put(MediaStore.MediaColumns.DATA, newFile.absolutePath)
values.put(MediaStore.MediaColumns.DISPLAY_NAME, newFile.name)
values.put(MediaStore.MediaColumns.TITLE, newFile.name)
val uri = if (oldFile.isImageSlow()) MediaStore.Images.Media.EXTERNAL_CONTENT_URI else MediaStore.Video.Media.EXTERNAL_CONTENT_URI
val updated = activity.contentResolver.update(uri, values, "${MediaStore.MediaColumns.DATA} = '${oldFile.absolutePath}'", null) == 1