Code example for MediaScannerConnection

Methods: scanFile

0
        public void setScanPath(String path) {
            mPath = path;
        } 
 
        @Override 
        public void onMediaScannerConnected() { 
            mScannerConnection.scanFile(mPath, null);
        } 
 
        @Override 
        public void onScanCompleted(String path, Uri uri) {
            mScannerConnection.disconnect();
 
            // try to start an activity to view the file 
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try { 
                mContext.startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(mContext, R.string.start_activity_failed_message,
                        Toast.LENGTH_SHORT).show();
            }