I saved some images in my storage's specific folder.I have fro example 1.png,2.png and etc. I know how i can get all files's name.This is source
private void getAllElemetsFromStorage() {
String root_sd = Environment.getExternalStorageDirectory().toString();
File file = new File(root_sd + "/myfolder");
for (File f : file.listFiles()) {
if (f.isFile()) {
String name = f.getName();
Log.e("file names", name + "");
}}
}
This code working correct but i have one problem.I have some json and in my json i have file's name.How i can get all files name witch is not in my json and is my directory and how i can delete all this files? My goal is to save only files,witch are in my jsons and i want to delete all unused files from my directory How i can solve my problem? thanks