获取其他应用的SharedPreferences共享内存

来源:互联网 发布:知乎怎么开通值乎 编辑:程序博客网 时间:2024/05/15 10:37
Log.d(TAG, "--------boot start");Context mContextSharedPreferences = null;try {// 获取其他程序所对应的ContextmContextSharedPreferences = mContext.createPackageContext("com.android.settings", Context.MODE_WORLD_READABLE);} catch (NameNotFoundException e) {e.printStackTrace();return false;}// 使用其他程序的Context获取对应的SharedPreferencesSharedPreferences prefs = mContextSharedPreferences.getSharedPreferences("bootstart", Context.MODE_WORLD_READABLE);// 读取数据int boot_position_enable = prefs.getInt("boot_position_enable", 0);int boot_position_tv = prefs.getInt("boot_position_tv", 0);int boot_position_vod = prefs.getInt("boot_position_vod", 0);int boot_position_app = prefs.getInt("boot_position_app", 0);String bootPackage = prefs.getString("bootPackage", "");String bootClass = prefs.getString("bootClass", "");