- File f = new File(mFile.getStoragePath());
- String newStoragePath = f.getParent() + mNewName;
- if (f.renameTo(new File(newStoragePath))) {
- mFile.setStoragePath(newStoragePath);
+ String oldPath = mFile.getStoragePath();
+ File f = new File(oldPath);
+ String parentStoragePath = f.getParent();
+ if (!parentStoragePath.endsWith(File.separator))
+ parentStoragePath += File.separator;
+ if (f.renameTo(new File(parentStoragePath + mNewName))) {
+ String newPath = parentStoragePath + mNewName;
+ mFile.setStoragePath(newPath);
+
+ // notify MediaScanner about removed file
+ getStorageManager().deleteFileInMediaScan(oldPath);
+ // notify to scan about new file
+ getStorageManager().triggerMediaScan(newPath);