If you think the Android project SDCardTrac listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* SDCardTrac application - keeps track of the /sdcard usage
* Copyright (C) 2012 Narendra M.A./*www.java2s.com*/
*/package com.nma.util.sdcardtrac;
import android.os.FileObserver;
import android.util.Log;
publicclass UsageFileObserver extends FileObserver {
private FileObserverService notifyThis;
String basePath;
public UsageFileObserver (String filePath, int eventMask, FileObserverService notifyMe) {
super(filePath, eventMask);
notifyThis = notifyMe;
basePath = filePath;
}
@Override
publicvoid onEvent(int event, String path) {
String locPath = basePath + "/" + path;
if (SettingsActivity.ENABLE_DEBUG)
Log.d(getClass().getName(), "Event seen: 0x" + Integer.toHexString(event) + " @ " + locPath);
if (path != null) { // Enqueue only if valid, sometimes null returned after delete
notifyThis.queueEvent(locPath, event, this); // Send to service
}
}
}