Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.ContentValues;
import android.content.Context;

import android.net.Uri;
import android.util.Log;

public class Main {
    /**
     * Constants
     */
    public static final Uri CONTENT_URI = Uri.parse("content://com.aspire.android.daemon/sharedconfig");
    public static final String KEY_CONNECT_MODE = "aspire_connect_mode";

    /**
     * set connect mode
     * @param context
     * @param value
     */
    public static void setConnectMode(Context context, String value) {
        set(context, KEY_CONNECT_MODE, value);
    }

    /**
     * set the value to share config
     * @param context context 
     * @param key key of the config
     * @param value value of the config
     */
    public static void set(Context context, String key, String value) {
        ContentValues values = new ContentValues();
        values.put("key", key);
        values.put("value", value);
        try {
            context.getContentResolver().insert(CONTENT_URI, values);
        } catch (IllegalArgumentException e1) {
        } catch (Exception e) {
            Log.e("AspShareUtil", "Error while set", e);
        }
    }
}