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 java.io.File;

public class Main {
    public static File getFileName(String dirPath, String fileName, Context context) {
        File mLogDir;
        if (isSDCardAvailable()) {
            mLogDir = new File(
                    Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + dirPath);
        } else {
            mLogDir = new File(context.getFilesDir().getAbsolutePath() + File.separator + dirPath);
        }
        if (!mLogDir.exists()) {
            mLogDir.mkdirs();
        }
        return new File(mLogDir.getAbsolutePath() + File.separator + fileName);
    }

    public static boolean isSDCardAvailable() {
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    }
}