Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.annotation.TargetApi;
import android.content.Context;

import android.os.Build;
import android.os.Environment;

import java.io.File;

public class Main {
    /**
     * Get the external app cache directory.
     *
     * @param context The context to use
     * @return The external cache dir
     */
    @TargetApi(Build.VERSION_CODES.FROYO)
    private static File getExternalCacheDir(Context context) {
        File f;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
            f = context.getExternalCacheDir();
            if (f != null) {
                return f;
            }
        }

        // Before Froyo we need to construct the external cache dir ourselves
        final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
        f = new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
        return f;
    }
}