标签:android style blog class code java
在APK的manifest节点中保证其 android:sharedUserId="hello.miles" 保持一致,名称可以自定义
// 创建共享数据的APK 其manifest包名为com.miles.sharedata SharedPreferences sp = Context.getSharedPreferences(String name, int mode) Editor editor = sp.edit() // 存值 editor.putBoolean("share1", true); editor.putInt("share2", 10); ... editor.commit();
// 读取共享数据的APK Context context = Context.createPackageContext("com.miles.sharedata", Context.CONTEXT_IGNORE_SECURITY); SharedPreferences preferences = context.getSharedPreferences(String name, int mode ); // 取值操作 boolean share1 = preferences.getBoolean("share1", false); int share2 = preferences.getInt("share2", 0); ...
标签:android style blog class code java
原文地址:http://www.cnblogs.com/smile365/p/3709370.html