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

import android.content.Context;

import android.os.Environment;

public class Main {
    public static boolean isFilesReady(Context context) {
        File hpDir = getSDDir(context);
        if (!hpDir.exists() || !hpDir.isDirectory()) {
            return false;
        }
        File hp = new File(hpDir, "hp48");
        File rom = new File(hpDir, "rom");
        File ram = new File(hpDir, "ram");
        return hp.exists() && hp.length() > 0 && rom.exists() && rom.length() > 0 && ram.exists()
                && ram.length() > 0;
    }

    public static File getSDDir(Context context) {
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            // We can read and write the media
            return context.getExternalFilesDir(null);
        } else {
            // Load another directory, probably local memory
            return context.getFilesDir();
        }
    }
}