import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.utils.FileStorageUtils;
-
import android.accounts.Account;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
+import android.content.Intent;
import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
).withSelection(where, whereArgs).build());
if (file.isDown()) {
+ String path = file.getStoragePath();
new File(file.getStoragePath()).delete();
+
+ // Notify MediaScanner about removed file
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent.setData(Uri.fromFile(new File(path)));
+ MainApp.getAppContext().sendBroadcast(intent);
}
}
}
success &= removeLocalFolder(file);
} else {
if (file.isDown()) {
+ String path = file.getStoragePath();
File localFile = new File(file.getStoragePath());
success &= localFile.delete();
if (success) {
file.setStoragePath(null);
saveFile(file);
+
+ // Notify MediaScanner about removed file
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent.setData(Uri.fromFile(new File(path)));
+ MainApp.getAppContext().sendBroadcast(intent);
}
}
}
if (localFile.isDirectory()) {
success &= removeLocalFolder(localFile);
} else {
+ String path = localFile.getAbsolutePath();
success &= localFile.delete();
+
+ // Notify MediaScanner about removed file
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent.setData(Uri.fromFile(new File(path)));
+ MainApp.getAppContext().sendBroadcast(intent);
}
}
}
}
Log_OC.d(TAG, "Local file RENAMED : " + renamed);
+ // Notify MediaScanner about removed file
+ Intent intent1 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent1.setData(Uri.fromFile(new File(file.getStoragePath())));
+ MainApp.getAppContext().sendBroadcast(intent1);
+
+ // Notify MediaScanner about new file/folder
+ Intent intent2 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent2.setData(Uri.fromFile(new File(defaultSavePath + targetPath)));
+ MainApp.getAppContext().sendBroadcast(intent2);
+
+ Log_OC.d(TAG, "uri old: " + file.getStoragePath());
+ Log_OC.d(TAG, "uri new: " + defaultSavePath + targetPath);
}
}