How to update gallery after program moving?

I move the photo from the directory to another using the following code

File oldfile= new File(originalImagePath); File newfile=new File(newImagePath); boolean d=oldfile.renameTo(newfilee); if(d){ sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + newfilee.getPath()))); } 

the photos have been moved to the new catalog successfully, but it takes too much time when the photos are counted more to update the galleries and gallery updates after about 30 seconds or more. So give me a suggestion what should I do if the logic for updating the file using sendBroadcast is incorrect

Thanks.

+8
android photo-gallery
source share
2 answers

remove from gallery

 try { getContentResolver().delete(); } catch (Exception e) { e.printStackTrace(); } 
+18
source share
 if (Build.VERSION.SDK_INT < 19) mContext.sendBroadcast(new Intent( Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); else { MediaScannerConnection .scanFile( mContext, new String[]{imageFile.toString()}, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted( String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); } }); } 
+1
source share

All Articles