You want something like this in your activity: import android.media.MediaScannerConnection; import android.media.MediaScannerConnection.MediaScannerConnectionClient;
private static class MediaScannerNotifier implements MediaScannerConnectionClient { private Context mContext; private MediaScannerConnection mConnection; private String mPath; private String mMimeType; public MediaScannerNotifier(Context context, String path, String mimeType) { mContext = context; mPath = path; mMimeType = mimeType; mConnection = new MediaScannerConnection(context, this); mConnection.connect(); } public void onMediaScannerConnected() { mConnection.scanFile(mPath, mMimeType); } public void onScanCompleted(String path, Uri uri) { // OPTIONAL: scan is complete, this will cause the viewer to render it try { if (uri != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); mContext.startActivity(intent); } } finally { mConnection.disconnect(); mContext = null; } } } To scan a file, you just create a new MediaScannerNotifier: new MediaScannerNotifier(path, mimeType); On Feb 14, 9:45 am, kolby <kolbys...@gmail.com> wrote: > You can make an android.media.MediaScannerConnection, connect to it, > and provide a client to scan a directory. > > Michael > > On Feb 14, 7:05 am, "info.sktechnol...@gmail.com" > > <info.sktechnol...@gmail.com> wrote: > > If I progammatically store new media files on the SD card, the > > MediaStore does not know about them until I remove and reinsert the SD > > card. Is there a way to tell the MediaStore to rescan the SD card > > without first unmounting the SD card? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---