Code example for MediaScannerConnection

Methods: scanFile

	public void onMediaScannerConnected() { 
		msc.scanFile(f.getAbsolutePath(), null);
	public void onScanCompleted(String path, Uri uri) {
		((OnMediaScannedListener) a).onMediaScanned(uri);
	public static Uri getUriFromFile(Context context, File file) {
		Uri uri = null;
		ContentResolver cr = context.getContentResolver();
		Cursor c = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] {BaseColumns._ID}, MediaStore.Images.Media.DATA + "=?", new String[] {file.getAbsolutePath()}, null);
		if(c != null && c.moveToFirst()) {
			uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(c.getLong(c.getColumnIndex(BaseColumns._ID))));
Connect your IDE to all the code out there  Get Codota for Java