Ich arbeite an einem Projekt, das ein Modul enthält, um pdf, doc xls-Dateien von SD-Karte zu scannen und eine Liste von ihnen zu machen. Ich möchte auch nur eine Liste von Ordnern machen.So scannen Sie SD-Karte für bestimmte Erweiterung von Dateien in Android?
Da bin ich sehr neu auf Android. Jeder hat eine Idee, dies zu erreichen.
Hier ist mein Code:
public class MediaScannerWrapper implements
MediaScannerConnection.MediaScannerConnectionClient {
private MediaScannerConnection mConnection;
private String mPath;
private String mMimeType;
// filePath - where to scan;
// mime type of media to scan i.e. "image/jpeg".
// use "*/*" for any media
public MediaScannerWrapper(Context ctx, String filePath, String mime){
mPath = filePath;
mMimeType = mime;
mConnection = new MediaScannerConnection(ctx, this);
}
// do the scanning
public void scan() {
mConnection.connect();
}
// start the scan when scanner is ready
public void onMediaScannerConnected() {
mConnection.scanFile(mPath, mMimeType);
Log.w("MediaScannerWrapper", "media file scanned: " + mPath);
}
public void onScanCompleted(String path, Uri uri) {
// when scan is completes, update media file tags
}
}
Haben Sie versucht, [Tiefensuche] (http://en.wikipedia.org/wiki/Depth-first_search) oder [Breitensuche] (http://en.wikipedia.org/ wiki/Brother-first_search)? – rekire