I insert an image via:
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, filename);
values.put(Images.Media.DATE_ADDE
taken from: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.html
This worked for me ( tested on HTC Desire, Android 2.3)
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(this,new String[] { file.toString() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
MediaScannerConnection.scanFile(context,new String[]{selectedVideoDelete}, null, null);
} else {
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
}
Add this right after deleting a file:
MediaScannerConnection.scanFile(context, arrayOf(imageURI.getPath()), null, null)
:)