Skip to content

Commit c57f3aa

Browse files
committed
rescan the files or folders after rename or delete
1 parent 033f99a commit c57f3aa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Intent;
77
import android.content.res.Resources;
88
import android.graphics.Color;
9+
import android.media.MediaScannerConnection;
910
import android.net.Uri;
1011
import android.os.Bundle;
1112
import android.support.annotation.Nullable;
@@ -413,6 +414,8 @@ public void onClick(View v) {
413414
}
414415

415416
if (currFile.renameTo(newFile)) {
417+
rescanFolder(newFile);
418+
MediaScannerConnection.scanFile(getContext(), new String[]{currFile.getAbsolutePath(), newFile.getAbsolutePath()}, null, null);
416419
alertDialog.dismiss();
417420
fillItems();
418421
} else {
@@ -585,6 +588,16 @@ private void deleteItems() {
585588
mToBeDeleted.clear();
586589
}
587590

591+
private void rescanFolder(File item) {
592+
if (item.isDirectory()) {
593+
for (File child : item.listFiles()) {
594+
rescanFolder(child);
595+
}
596+
}
597+
598+
MediaScannerConnection.scanFile(getContext(), new String[]{item.getAbsolutePath()}, null, null);
599+
}
600+
588601
private void deleteItem(File item) {
589602
if (item.isDirectory()) {
590603
for (File child : item.listFiles()) {
@@ -593,6 +606,7 @@ private void deleteItem(File item) {
593606
}
594607

595608
item.delete();
609+
MediaScannerConnection.scanFile(getContext(), new String[]{item.getAbsolutePath()}, null, null);
596610
}
597611

598612
private View.OnClickListener undoDeletion = new View.OnClickListener() {

0 commit comments

Comments
 (0)