// Context.CONTEXT_IGNORE_SECURITY 忽略安全检测
//getContext().createPackageContext 创建其它应该程序的上下文对象
Context otherContext= getContext().createPackageContext("cn.itcast.preferences", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences prefence= otherContext.getSharedPreferences("itcast", Context.MODE_PRIVATE);

String nameString= prefence.getString("name", "侯志敏");
int ageInt= prefence.getInt("age", 25);
Log.i(TAG, "name:"+nameString+"========age:"+ageInt);

更多相关文章

  1. Android(安卓)高德定位展示当前位置在地图上
  2. android中-----JSON例子一、 二
  3. 【stagefrightplayer】1 调用过程
  4. Android(安卓)开发笔记1 (MTK)
  5. Android(安卓)AOSP 环境下实现C++直接调用libmedia.so接口播放视
  6. Android(安卓)一些指令
  7. android细节知识小点(动态更新)
  8. Android(安卓)高效的SQLite型数据库greenDAO使用
  9. java.lang.IllegalArgumentException: connection is null 绑定

随机推荐

  1. Android之高仿手机QQ图案解锁
  2. [Android(安卓)Pro] Notification的使用
  3. android 反编译必知-public.xml
  4. TableLayout
  5. Softap热点原理分析
  6. android头文件路径
  7. recovery代码流程
  8. android 打开扬声器
  9. Android(安卓)TextView自动换行
  10. Android(安卓)BaseExpandableListAdapter