Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import java.io.File;

public class Main {
    /**
     * Application cache sub-directory. Note that this name must be exactly the
     * same name used in the resource xml/file_paths.xml to support the
     * applications file provider implementation.
     */
    private static final String CACHE_DIRNAME = "download";
    /**
     * Sub-folder within the cache that can be used to store temporary files.
     * This subfolder should be periodically cleared so that any file entries
     * left over from abnormal app termination will not waste system resources.
     */
    private static final String TEMP_DIRNAME = "temp";

    /**
     * Constructs a path name to a unique temporary file within the caches'
     * temporary sub-directory.
     *
     * @return Application temporary sub-directory path.
     */
    public static String getTempDirPathName(Context context) {
        return getCacheDirPathName(context) + File.separator + TEMP_DIRNAME;
    }

    /**
     * Gets the current application cache directory path in private storage.
     *
     * @param context Any context.
     * @return The default application cache directory path.
     */
    public static String getCacheDirPathName(Context context) {
        return context.getApplicationContext().getCacheDir() + File.separator + getCacheDirName();
    }

    /**
     * @return Application cache directory sub-folder name.
     */
    private static String getCacheDirName() {
        return CACHE_DIRNAME;
    }
}