以保存扫描二维码得到网址为例:
保存:
SharedPreferences sharedPref = getSharedPreferences("remember",
Context.MODE_PRIVATE);
Editor editor = sharedPref.edit();
editor.putString("url", resultString);//<span style="font-family: Arial, Helvetica, sans-serif;">resultString是二维码扫描出的信息</span>
editor.commit();
取信息:
SharedPreferences sharedPref = this.getSharedPreferences(
"remember", Context.MODE_PRIVATE);
String nullUrl = "http://www.baidu.com";
String sUrl = sharedPref.getString("url", nullUrl);