Android Open Source - twitter4a Util






From Project

Back to project page twitter4a.

License

The source code is released under:

Apache License

If you think the Android project twitter4a listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.leolink.android.twitter4a.utils;
//from ww  w . ja va  2s  .  c om
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.util.Log;

/**
 * Created by leolink on 6/14/14.
 */
public class Util {
    public static final String TAG = "Twitter4A";

    /* Logging utilities */
    public static void log(Object obj) {
        Log.e(TAG, String.valueOf(obj));
    }
    public static void logd(Object obj) {
        Log.e(TAG, String.valueOf(obj));
    }

    /* SharedPreferences utilities */
    public static void spPutString(Context context, String key, String value) {
        SharedPreferences.Editor editor = context.getSharedPreferences(
                Const.SP_TWITTER4A_FILE_NAME, Context.MODE_PRIVATE).edit();
        editor.putString(key, value);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            editor.commit();
        } else {
            editor.apply();
        }
    }
    public static String spGetString(Context context, String key, String defaultValue) {
        return context.getSharedPreferences(Const.SP_TWITTER4A_FILE_NAME, Context.MODE_PRIVATE)
                .getString(key, defaultValue);
    }
    public static void spRemove(Context context, String key) {
        SharedPreferences.Editor editor = context.getSharedPreferences(
                Const.SP_TWITTER4A_FILE_NAME, Context.MODE_PRIVATE).edit();
        editor.remove(key);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            editor.commit();
        } else {
            editor.apply();
        }
    }
}




Java Source Code List

net.leolink.android.twitter4a.Twitter4A.java
net.leolink.android.twitter4a.utils.Const.java
net.leolink.android.twitter4a.utils.Util.java
net.leolink.android.twitter4a.widget.LoginDialog.java
net.leolink.android.twitter4a.widget.Spinner.java
net.leolink.android.twitter4aexample.Twitter4AExampleActivity.java