正在加载图片...
8.1 SharedPreferences ■访问其他应用程序的SharedPreferences需要的3个 条件: ▣访问模式为全局读或全局写 口 需要知道共享者的包名和SharedPreferences名称,通过 Context获取对象 需要知道每个数据的名称和数据类型以读取数据 Context otherAppsContext createPackageContext("cn.itcast.action", Context.CONTEXT_IGNORE_SECURITY); SharedPreferences sharedPreferences otherAppsContext.getSharedPreferences("itcast", Context.MODE WORLD READABLE); String name sharedPreferences.getString("name",M); int age sharedPreferences.getInt("age",0); n 访问其他应用程序的SharedPreferences需要的3个 条件: q 访问模式为全局读或全局写 q 需要知道共享者的包名和SharedPreferences名称,通过 Context获取对象 q 需要知道每个数据的名称和数据类型以读取数据 8.1 SharedPreferences Context otherAppsContext = createPackageContext("cn.itcast.action", Context.CONTEXT_IGNORE_SECURITY); SharedPreferences sharedPreferences = otherAppsContext.getSharedPreferences("itcast", Context.MODE_WORLD_READABLE); String name = sharedPreferences.getString("name", ""); int age = sharedPreferences.getInt("age", 0);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有