Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.os.Environment;

import java.io.File;

public class Main {
    public static File getAppCacheFile(Context context) {
        File externalCacheDir;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || !Environment.isExternalStorageRemovable()) {
            externalCacheDir = context.getExternalCacheDir();
            // context.getExternalCacheDir() maybe null
            if (externalCacheDir == null) {
                externalCacheDir = context.getCacheDir();
            }
        } else {
            externalCacheDir = context.getCacheDir();
        }
        return externalCacheDir;
    }
}