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 String pathPrefix;
    private static File storageDir = null;

    private static File generateMessagePath(String var0, String var1, Context context) {
        File file = new File(generateHistoryPath(var0, var1, context), var1 + File.separator + "Msg.db");
        return file;
    }

    private static File generateHistoryPath(String var0, String var1, Context context) {
        String name = null;
        if (var0 == null) {
            name = pathPrefix + var1 + "/chat/";
        } else {
            name = pathPrefix + var0 + "/" + var1 + "/chat/";
        }

        return new File(getStorageDir(context), name);
    }

    private static File getStorageDir(Context context) {
        if (storageDir == null) {
            File file = Environment.getExternalStorageDirectory();
            if (file.exists()) {
                return file;
            }

            storageDir = context.getFilesDir();
        }

        return storageDir;
    }
}