I have a basic question on MediaScanner pls help me in understanding this better.
MediaScanner for a folder returns only info about folder that is scanned but not contents of a folder for any media files present in it. If a folder is scanned for ex. /storage/extSdCard/DCIM/Camera
which has few .jpg files in it, I get scan response about the folder and not the about files in it. logs below,
D/MediaScannerConnection(29105): Connected to MediaScanner
D/MediaScannerConnection(29105): Scanning file 7klwibgf7fxlKdCbid7DCRV7Cbvfib
D/MyLog(29105): onScanCompleted(path,uri), path: /storage/extSdCard/DCIM/Camera, Uri: content://media/external/file/4334
My question,
Is it possible to get events back when ever a media file is added to folder of my interest in this case it is, /storage/extSdCard/DCIM/Camera
public void MyScanner(String filename){
File fileCheck = new File(filename);
conn = new MediaScannerConnection(this,this);
conn.connect();
}
@Override
public void onMediaScannerConnected() {
Log.d(TAG,"onMediaScannerConnected() to MediaScanner Service");
conn.scanFile(filename, null);
}
@Override
public void onScanCompleted(String path, Uri uri) {
if(path!=null && uri!=null)
Log.d(TAG,"onScanCompleted(), path: "+path+", Uri: "+uri.toString());
Log.d(TAG,"Converting file uri to FilePath: "+getRealPathFromURI(uri));
}
Second one code..