Code example for File

Methods: delete, getPath

0
        // Note: needs listening at event ATTRIB rather than CLOSE_WRITE, because we set the 
        // readability of snapshot files after writing them! 
        snapshotObserver = new FileObserver(SNAPSHOT_DIR, FileObserver.ATTRIB) {
            @Override 
            public void onEvent(int event, String path) {
                handleSnapshotFile(new File(SNAPSHOT_DIR, path), dropbox);
            } 
        }; 
        snapshotObserver.startWatching();
 
        if (LOCAL_LOGV) Slog.v(TAG, "SamplingProfilerService activated");
    } 
 
    private void handleSnapshotFile(File file, DropBoxManager dropbox) {
        try { 
            dropbox.addFile(TAG, file, 0);
            if (LOCAL_LOGV) Slog.v(TAG, file.getPath() + " added to dropbox");
        } catch (IOException e) {
            Slog.e(TAG, "Can't add " + file.getPath() + " to dropbox", e);
        } finally { 
            file.delete();
        } 
    } 
 
    private void registerSettingObserver(Context context) {
        ContentResolver contentResolver = context.getContentResolver();