漂定

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

写入:

    public static Boolean setShareData(Context context,String name,String pass){
        SharedPreferences sp = context.getSharedPreferences("loginConfig", Context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("uname", name);
        editor.putString("pass", pass);
        return editor.commit();
    }

读取:

        SharedPreferences sp = getSharedPreferences("loginConfig", Context.MODE_PRIVATE);
        String name = sp.getString("name", "");
        String pass = sp.getString("pass", "");

 

posted on 2013-11-01 10:24  漂定  阅读(402)  评论(0编辑  收藏  举报