First, the current process is also the current project inside the storage
Sharedpreferences.editor Editor = mcontext.getsharedpreferences ("Tvplay", Context.mode_private). Edit ();
Editor.putstring ("Video", Content.getstring ("video"));
Editor.commit ();
This is the storage
Sharedpreferences preferences = Gettargetcontext (). Getsharedpreferences ("Tvplay", context.mode_private);
Video = preferences.getstring ("video", "");
This is taken
Sharedpreferences process Storage across processes
Sharedpreferences.editor Editor = mcontext.getsharedpreferences ("Tvplay", context.mode_world_readable). Edit ();
Editor.putstring ("Video", Content.getstring ("video"));
Editor.commit ();
This is the only difference between the deposit and the above is the mode change, do not understand Baidu can!
private static final String Target_package_name = "Com.sdmc.hotel.ollauncher";//The package name of the target data program,
Sharedpreferences preferences = Gettargetcontext (). Getsharedpreferences ("Tvplay", context.mode_private);
Video = preferences.getstring ("video", "");
Private Context Gettargetcontext () {
try {
Return Createpackagecontext (Target_package_name, context.context_ignore_security);
} catch (Namenotfoundexception e) {
E.printstacktrace ();
}
return null;
}
This is different from the above is to create a context for the process you want to take, and then call the Getsharedpreferences () method
Android Sharedpreferences Lightweight Storage!