Code example for MediaScannerConnection

Methods: isConnected, scanFile

0
		scanner = new MediaScannerConnection(context, this);
		scanner.connect();
	} 
 
	private synchronized void scanFile(String path) {
		scanner.scanFile(path, null);
		fileScanning.add(path);
	} 
 
	public synchronized void scanFile(File file) {
		if (scanner.isConnected()) {
			scanFile(file.getAbsolutePath());
		} else { 
			fileToScan.add(file.getAbsolutePath());
		} 
	} 
 
	@Override 
	public synchronized void onMediaScannerConnected() { 
		for (String file : fileToScan)
			scanFile(file);