I'm trying to use scanFile()
to scan a file I have created using DocumentFile
. It would appear that this function does not work with a DocumentFile
's uri/path. Is there any way to get them to work together or another method to invoke the media scanner?
DocumentFile myDir = DocumentFile.fromTreeUri(getApplicationContext(),MainActivity.myStrDir).findFile("Folder").findFile("test.mp4");
scanFile(myDir.getUri().getPath());
private void scanFile(String filePath) {
MediaScannerConnection.scanFile(mContext, new String[]{filePath},
null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String file, Uri fileUri) {
mHandler.post(mUIUpdateHandler);
}
});
}