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 delServerConfig(Context ctx) {
        if (ctx == null) {
            throw new IllegalArgumentException("Context can't null.");
        }
        String sdkServerFolder = getSDKServerFolder(ctx);
        File file = new File(sdkServerFolder, SDK_SERVER_NAME);
        if (file.exists()) {
            file.delete();
        }
        return true;
    }

    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();
    }
}