Android(安卓)创建其它应该程序的上下文对象
16lz
2021-01-24
// 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);
更多相关文章
- Android(安卓)高德定位展示当前位置在地图上
- android中-----JSON例子一、 二
- 【stagefrightplayer】1 调用过程
- Android(安卓)开发笔记1 (MTK)
- Android(安卓)AOSP 环境下实现C++直接调用libmedia.so接口播放视
- Android(安卓)一些指令
- android细节知识小点(动态更新)
- Android(安卓)高效的SQLite型数据库greenDAO使用
- java.lang.IllegalArgumentException: connection is null 绑定