put Shared Data to SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

put Shared Data to SharedPreferences

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Main {
    public static final String KEY = "org.aisen.android.activityhelp_key";
    private static Context mContext;

    public static void putShareData(String key, String value) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        Editor et = sp.edit();//from www.  j  av a2 s.c o m
        et.putString(key, value);
        et.commit();
    }
}

Related Tutorials