1 package com.yuji.em.utility;
\r
3 import android.content.Context;
\r
4 import android.content.SharedPreferences;
\r
5 import android.content.SharedPreferences.Editor;
\r
6 import android.content.pm.PackageManager.NameNotFoundException;
\r
8 public class PrefUtilImpl implements PrefUtil {
\r
9 private Context context;
\r
11 public PrefUtilImpl(Context context) {
\r
12 this.context = context;
\r
15 public void put(String key, String value) {
\r
16 synchronized (this) {
\r
17 SharedPreferences pref = null;
\r
19 Context ctxt = context.createPackageContext("com.yuji.em",
\r
20 Context.CONTEXT_RESTRICTED);
\r
21 pref = ctxt.getSharedPreferences("EverMemoActivity",
\r
22 Context.MODE_WORLD_READABLE
\r
23 | Context.MODE_WORLD_WRITEABLE);
\r
24 } catch (NameNotFoundException e) {
\r
26 // Debug.l(e.getMessage());
\r
28 // Debug.d(this, null, e);
\r
32 Editor e = pref.edit();
\r
33 e.putString(key, value);
\r
38 public void put(String key, int value) {
\r
39 put(key, String.valueOf(value));
\r
42 public String get(String key) {
\r
45 synchronized (this) {
\r
46 SharedPreferences pref = null;
\r
48 Context ctxt = context.createPackageContext("com.yuji.em",
\r
49 Context.CONTEXT_RESTRICTED);
\r
50 pref = ctxt.getSharedPreferences("EverMemoActivity",
\r
51 Context.MODE_WORLD_READABLE);
\r
52 } catch (NameNotFoundException e) {
\r
54 // Debug.l(e.getMessage());
\r
56 // Debug.d(this, null, e);
\r
59 val = pref.getString(key, null);
\r
65 public int getInt(String key) {
\r
66 return Integer.parseInt(get(key));
\r
69 public String get(String key, String initValue) {
\r
70 String value = get(key);
\r
71 if (value != null) {
\r
74 put(key, initValue);
\r
78 public int getInt(String key, int initValue) {
\r
79 return Integer.valueOf(get(key, String.valueOf(initValue)));
\r
82 public void remove(String key) {
\r