Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean renameVideoFile(Context mContext, File from, File to) {
- if (from.getParentFile().exists() && from.exists() && from.renameTo(to)) {
- removeMedia(mContext, from);
- addMedia(mContext, to);
- return true;
- } else {
- return false;
- }
- }
- public static void addMedia(Context mContext, File file) {
- Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file));
- mContext.sendBroadcast(intent);
- }
- public static void removeMedia(Context mContext, File file) {
- try {
- ContentResolver resolver = mContext.getContentResolver();
- resolver.delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.DATA + "=?", new String[]{file.getAbsolutePath()});
- } catch (Exception e){
- Debug.e("--- removeMedia: " + e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement