Reputation: 145
I have a public question.In android ,How can refresh or restart MediaStore after adding or deleting or any modifying files on the SDcard? I can call this after my modinfing on SDcard but i dont like use this.becuse may be exists another better ways.any help appreciate me.
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
Upvotes: 1
Views: 2803
Reputation: 145
I find response for my post. i use this method after deleting or adding or any midifying on sdcard.
static void scanWithPath(Context cont,String[] pathes)
{
OnScanCompletedListener callback=new OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
//the work which want to do when scan completed
}
};
MediaScannerConnection.scanFile(cont, paths, mimeTypes, callback);
}
we need only context and a string array from pathes which decide to scann those. I write this method in a java calss.and becuse scanFile method need to a context so I passed it to method. i wish this helped you.
Upvotes: 4