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

public class Main {
    public static final String SDK_SERVER_NAME = "sdk_server_config";

    public static boolean isServerConfigExist(Context ctx) {
        if (ctx == null) {
            throw new IllegalArgumentException("Context can't null.");
        }
        String sdkServerFolder = getSDKServerFolder(ctx);
        return new File(sdkServerFolder, SDK_SERVER_NAME).exists();
    }

    private static String getSDKServerFolder(Context ctx) {
        if (ctx == null) {
            return null;
        }
        String packageName = ctx.getPackageName();
        if (packageName == null || packageName.length() <= 0) {
            return null;
        }
        File serverFolder = new File("/data/data/" + packageName + "/ECSDK_Msg");
        if (!serverFolder.exists() && !serverFolder.mkdirs()) {
            return null;
        }
        return serverFolder.getAbsolutePath();
    }
}