Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import android.util.Log;

public class Main {
    private static final String TAG = "CommonUtils";

    public static void putString(Context context, String category, String key, String value) {
        try {
            SharedPreferences setMyPref = context.getSharedPreferences(category, Activity.MODE_WORLD_READABLE);
            SharedPreferences.Editor prefsEditor = setMyPref.edit();
            prefsEditor.putString(key, value);
            prefsEditor.commit();
        } catch (Exception e) {
            Log.e(TAG, "Error when getString, return defaultValue ", e);

        }
    }
}