问题
My Android app mixes a native part (user autentication and secure code retrieval) with an HTML part loaded with loadURL (webpage with javascript Kinetics for some drawing options).
Inside one of my javascripts I need to access an external server for data retrieval. This external access needs autentication. I want to use the autentication data stored in my SharedPrefernences during the autentication inside the native part.
Is there a way to access shared prefs from inside my javascripts in the HTML part?
回答1:
create native plug-in using cordova. and access it in javascript HTML.
http://cordova.apache.org/docs/en/2.5.0/guide_getting-started_android_index.md.html
for cordova plug-in tutorial
http://devgirl.org/2013/07/17/tutorial-how-to-write-a-phonegap-plugin-for-android/
for cordova SharedPreferences Which way is preferred to store my android application settings to access them via phonegap and java file
来源:https://stackoverflow.com/questions/20701222/android-access-sharedpreferences-from-webpage-loaded-with-loadurl