I’m trying to add a file in my data directory on my sdcard to the mediastore content provider. However, I fear that I may have a java education issue on my hands. MediaScannerConnectionClient is purportedly a nested class of MediaScannerConnection, but this syntax won’t compile.
Here is the link to the MediaScannerConnection API: http://developer.android.com/reference/android/media/MediaScannerConnection.html
What would be the appropriate way to reference scanner?
Thanks!
final String filename = (new File(img.uri.toString())).getAbsolutePath().substring(6);
final MediaScannerConnection scanner = new MediaScannerConnection(this,
new MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
MediaScannerConnection.this.scanFile(filename, null /*mimeType*/);
}
public void onScanCompleted(String path, Uri uri) {
MediaScannerConnection.this.disconnect();
}
});
scanner.connect();
I finally found my answer in an example.
…/android-8/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java