源码简介
一款仿iPhone的密码锁,带有动画效果。
源码运行截图
源码片段
- public class DBSharedPreferences {
- private Context context;
- public static final String _NAME = "DIARY_DB";
- public static final String _USERD = "_USERD";
- public DBSharedPreferences(Context context) {
- this.context = context;
- }
- // ///////////////////////////////////////////String///////////////////////////////////////////////////
- public void putString(String key, String value) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- Editor editor = sp.edit();
- editor.putString(key, value);
- editor.commit();
- }
- public String getString(String key) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- return sp.getString(key, "nothing");
- }
- // ///////////////////////////////////////////Integer///////////////////////////////////////////////////
- public void putInteger(String key, int value) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- Editor editor = sp.edit();
- editor.putInt(key, value);
- editor.commit();
- }
- public Integer getInteger(String key) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- return sp.getInt(key, -1);
- }
- // ///////////////////////////////////////////Boolean///////////////////////////////////////////////////
- public void putBoolean(String key, boolean value) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- Editor editor = sp.edit();
- editor.putBoolean(key, value);
- editor.commit();
- }
- public boolean getBoolean(String key) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- return sp.getBoolean(key, false);
- }
- // ///////////////////////////////////////////Long///////////////////////////////////////////////////
- public void putLong(String key, long value) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- Editor editor = sp.edit();
- editor.putLong(key, value);
- editor.commit();
- }
- public long getLong(String key) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- return sp.getLong(key, -1);
- }
- // ///////////////////////////////////////////Float///////////////////////////////////////////////////
- public void putFloat(String key, float value) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- Editor editor = sp.edit();
- editor.putFloat(key, value);
- editor.commit();
- }
- public float getFloat(String key) {
- SharedPreferences sp = context.getSharedPreferences(_NAME, 1);
- return sp.getFloat(key, 0.0F);
- }
- }
源码下载:http://down.51cto.com/data/1980604