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 android.os.Environment;

import java.io.File;

public class Main {
    public static File getExtWorkingDir(Context context) {
        if (!isExternalStorageWritable())
            return null;
        File workingDir = new File(Environment.getExternalStorageDirectory() + File.separator + "data");
        if (!workingDir.exists())
            workingDir.mkdir();
        workingDir = new File(workingDir + File.separator + getPackageName(context));
        if (!workingDir.exists())
            workingDir.mkdir();
        return workingDir;
    }

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

    public static String getPackageName(Context context) {
        return context.getPackageName();
    }
}