update mediastore after deleted files manually
This commit is contained in:
parent
1ae4e0cc02
commit
62d11861ca
1 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.gallery.activities
|
package com.simplemobiletools.gallery.activities
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.ContentValues
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
|
@ -219,8 +220,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanFile(file) {
|
val values = ContentValues()
|
||||||
|
values.put(MediaStore.MediaColumns.DATA, file.absolutePath)
|
||||||
|
val uri = if (file.isImageSlow()) MediaStore.Images.Media.EXTERNAL_CONTENT_URI else MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||||
|
val updated = contentResolver.delete(uri, "${MediaStore.MediaColumns.DATA} = '${file.absolutePath}'", null) == 1
|
||||||
|
|
||||||
|
if (updated) {
|
||||||
reloadViewPager()
|
reloadViewPager()
|
||||||
|
} else {
|
||||||
|
scanFile(file) {
|
||||||
|
reloadViewPager()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue