apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 210 forks source link

Can I specify a specific file for preferences for Android? #97

Closed pke closed 4 years ago

pke commented 8 years ago

I'm migrating a titanium app to cordova and titanium app preferences are saved in: /data/data/com.domainname.appname/shared_prefs/titanium.xml

is there a way to read this file with this plugin?

apla commented 7 years ago

Android have two possible calls to get shared preferences — default preferences and named ones. I've just added (commit e56013a23d64) possibility to work with named preferences on Android. I'm not sure about titanium preferences format and my code is untested, but you can try. Usage:

var appPrefs = plugins.appPreferences;
var titaniumPrefs = appPrefs.suite('titanium');
titaniumPrefs.fetch(…)

@benjaminpetrin hacked preference reading in his fork to do similar task: https://github.com/getadored/me.apla.cordova.app-preferences/commit/32893cf05adeec4fc7b6eaf4c66ce16bf5467306

apla commented 7 years ago

There is a wiki page about that functionality: Suites