Java Code Examples for android.os.FileUtils#deleteContents()

The following examples show how to use android.os.FileUtils#deleteContents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskPersister.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
TaskPersister(File systemDir, ActivityStackSupervisor stackSupervisor,
        ActivityManagerService service, RecentTasks recentTasks) {

    final File legacyImagesDir = new File(systemDir, IMAGES_DIRNAME);
    if (legacyImagesDir.exists()) {
        if (!FileUtils.deleteContents(legacyImagesDir) || !legacyImagesDir.delete()) {
            Slog.i(TAG, "Failure deleting legacy images directory: " + legacyImagesDir);
        }
    }

    final File legacyTasksDir = new File(systemDir, TASKS_DIRNAME);
    if (legacyTasksDir.exists()) {
        if (!FileUtils.deleteContents(legacyTasksDir) || !legacyTasksDir.delete()) {
            Slog.i(TAG, "Failure deleting legacy tasks directory: " + legacyTasksDir);
        }
    }

    mTaskIdsDir = new File(Environment.getDataDirectory(), "system_de");
    mStackSupervisor = stackSupervisor;
    mService = service;
    mRecentTasks = recentTasks;
    mLazyTaskWriterThread = new LazyTaskWriterThread("LazyTaskWriterThread");
}
 
Example 2
Source File: ShortcutService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void cleanupBitmapsForPackage(@UserIdInt int userId, String packageName) {
    final File packagePath = new File(getUserBitmapFilePath(userId), packageName);
    if (!packagePath.isDirectory()) {
        return;
    }
    if (!(FileUtils.deleteContents(packagePath) && packagePath.delete())) {
        Slog.w(TAG, "Unable to remove directory " + packagePath);
    }
}