Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.os.Environment;
import android.util.Log;

import java.io.File;

public class Main {
    public static File getDiskCacheDir(Context context, String fileName) {
        String cachePath;
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
                && !Environment.isExternalStorageRemovable()) {
            cachePath = context.getExternalCacheDir().getPath();
        } else {
            cachePath = context.getCacheDir().getPath();
        }
        Log.d("bonus", "cachePath = " + cachePath);
        return new File(cachePath + File.separator + fileName);
    }
}