Sunday, January 10, 2016

sharepreference between different applications to read and write




            


ME .... ME .... ME .... I need an application A which is another one of those B inside sharepreference.xml file applications. But after I finished inside A to B application to view the time when the xml file has not changed. But read out in A it is already change. Code is as follows: A code is as follows:
 try {
otherAppsContext = MainActivity.this.createPackageContext ("com.example.sharepreferencewww", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences otherSharedPreferences = otherAppsContext.getSharedPreferences ("bbb", Context.MODE_WORLD_WRITEABLE);
Editor otherEditor = otherSharedPreferences.edit ();
otherEditor.putString ("aaa", "sssdd");
otherEditor.commit ();

} Catch (Exception e) {
// Log.d ("kk", "" + e.printStackTrace ());
e.printStackTrace ();
}

In the B Context.MODE_WORLD_WRITEABLE property has been set.

Help A

Reply:
quote landlord huangtians reply:
ME .... ME .... ME .... I need some other application in which an application A A B inside sharepreference.xml file. But after I finished inside A to B application to view the time when the xml file has not changed. But read out in A it is already change. Code is as follows: A code is as follows:


Java code
?



1234567891011

try {otherAppsContex ......


.... If you want to change the contents of the file you have to parse xml reader xml change the way ah ~ otherEditor.commit (); method can only change the value of the current data in the cache can not directly change the contents of xml
Reply:
quote 1 floor ConnectionUtils reply:
quote landlord huangtians reply: ME .... ME .... ME .... I need a A few other applications inside a B inside sharepreference.xml file applications. But after I finished inside A to B application to view the time when the xml file has not changed. But read out in A it is already change. Code is as follows: A code is as follows:


Java code
?



1234567891011

tr ......


Can give an example, I was in was too dishes, thank you ....!
Reply:
And why in the same application which should not parse xml files? This is very clear. Thank you!
Reply:
Had also encountered this problem later switched contentprovider, and look forward to solve.
Reply:
otherAppsContext = MainActivity.this.createPackageContext ("a package", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences otherSharedPreferences = otherAppsContext.getSharedPreferences ("bbb", Context.MODE_WORLD_WRITEABLE); B written on the inside of it
Reply:
quote 5th floor wlianghe00 reply:
otherAppsContext = MainActivity.this.createPackageContext ("a package", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences otherSharedPreferences = otherAppsContext.getSharedPreferences ("bbb", ......
understand what you say, I just want to modules such as calendar / information ring setting, move the setting inside, so to be. A is setting.b other modules.
Reply:
quote, 6th Floor huangtians reply:
quote 5th floor wlianghe00 reply:
otherAppsContext = MainActivity.this.createPackageContext ("a package", Context.CONTEXT_IGNORE_SECURITY);
SharedPreferences otherSharedPreferences = otherAppsContext.getSharedPrefere ......


If this is the case, you set the modified and vice versa in the same tones Setiings send a broadcast to inform the appropriate application to change
Reply:
Upstairs on the can, inter-process communication previously used aidl, later found to have problems logically, and again with broadcast
Reply:
Will com.android.settings_preferences.xml this setting module file is created there. Looking for a long time did not find.
Reply:
Asynchronous communication uses SharePreference.Edit (). Apply ()
Reply:
quote the 10th floor orangebook reply:
asynchronous communication uses SharePreference.Edit () apply ()

.Over the past so long I do not know the landlord did not solve, this man said is right, but you must be able to call this method reflected:
Class clz = SharedPreferences.Editor.class;
clz.getMethod ("apply") invoke (editor);.
for reference only
Reply:
getSharedPreferences ("data", Context.MODE_WORLD_WRITEABLE + Context.MODE_WORLD_READABLE + Context.MODE_MULTI_PROCESS); plus the authority will be able to read and write can be either synchronous

No comments:

Post a Comment