Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;
import android.database.Cursor;
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 AGENT_PORT_KEY = "aspire_agent_port";

    public static String getAgentPort(Context context) {
        return get(context, AGENT_PORT_KEY);
    }

    public static String get(Context context, String key) {
        String temp = null;
        Cursor cur = null;
        try {
            cur = context.getContentResolver().query(CONTENT_URI, null, "key='" + key + "'", null, null);
            if (null != cur && cur.moveToFirst())
                temp = cur.getString(1);

        } catch (Exception e) {
            Log.e("AspShareUtil", "Error while get", e);
        } finally {
            if (cur != null)
                cur.close();
        }
        return temp;
    }
}