Android: Refreshing the Gallery after saving new images

Code provided by Petrus in another answer works for me on Kitkat (4.4): MediaScannerConnection.scanFile(this, new String[] { Environment.getExternalStorageDirectory().toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { /* * (non-Javadoc) * @see android.media.MediaScannerConnection.OnScanCompletedListener#onScanCompleted(java.lang.String, android.net.Uri) */ public void onScanCompleted(String path, Uri uri) { Log.i(“ExternalStorage”, “Scanned ” + path + “:”); Log.i(“ExternalStorage”, “-> uri=” + uri); } });

retrieve absolute path when select image from gallery kitkat android

Here is one way to access the Absolute path after selecting file. After getting data in new URI format for KK(KitKat) like this way content://com.android.providers.media.documents/document/image:2505 Just extract ID of your document if(requestCode == GALLERY_KITKAT_INTENT_CALLED && resultCode == RESULT_OK){ Uri originalUri = data.getData(); final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Check for the … Read more

How can I display images from a specific folder on android gallery

Hi you can use the code below, i hope it helps you . package com.example.browsepicture; import java.io.File; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.media.MediaScannerConnection; import android.media.MediaScannerConnection.MediaScannerConnectionClient; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class BrowsePicture2 extends Activity { String SCAN_PATH; File[] allFiles ; public void onCreate(Bundle savedInstanceState) { … Read more

Android file delete leaves empty placeholder in Gallery

Android has a cache of sorts that keeps track of media files. Try this: sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(“file://” + Environment.getExternalStorageDirectory()))); It makes the MediaScanner service run again, which should remove the deleted image from the device’s cache. Looks like you also need to add this permission to your AndroidManifest.xml: <intent-filter> <action android:name=”android.intent.action.MEDIA_MOUNTED” /> <data android:scheme=”file” /> … Read more