sharedpreferences - Android app crashes by setting default values -



sharedpreferences - Android app crashes by setting default values -

i seek set default values in app.

i tried this:

preferencemanager.setdefaultvalues(this, r.xml.defaults, false);

and this

sharedpreferences settings = preferencemanager.getdefaultsharedpreferences(this); preferencemanager.setdefaultvalues(this, r.xml.defaults, false);

but crashes.

here res/xml/defaults.xml

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="programtitles">["x", "a", "b", "c", "d", "e"]</string> <string name="programsubs">["", "as", "bs", "cs", "ds", "es"]</string> </resources>

logcat:

10-09 08:16:21.820: w/dalvikvm(1557): threadid=1: thread exiting uncaught exception (group=0xb1a5fba8) 10-09 08:16:21.840: e/androidruntime(1557): fatal exception: main 10-09 08:16:21.840: e/androidruntime(1557): process: com.example.blauzahn, pid: 1557 10-09 08:16:21.840: e/androidruntime(1557): java.lang.runtimeexception: unable start activity componentinfo{com.example.blauzahn/com.example.blauzahn.mainactivity}: android.view.inflateexception: binary xml file line #2: error inflating class resources 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread.performlaunchactivity(activitythread.java:2195) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread.access$800(activitythread.java:135) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 10-09 08:16:21.840: e/androidruntime(1557): @ android.os.handler.dispatchmessage(handler.java:102) 10-09 08:16:21.840: e/androidruntime(1557): @ android.os.looper.loop(looper.java:136) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread.main(activitythread.java:5017) 10-09 08:16:21.840: e/androidruntime(1557): @ java.lang.reflect.method.invokenative(native method) 10-09 08:16:21.840: e/androidruntime(1557): @ java.lang.reflect.method.invoke(method.java:515) 10-09 08:16:21.840: e/androidruntime(1557): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 10-09 08:16:21.840: e/androidruntime(1557): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 10-09 08:16:21.840: e/androidruntime(1557): @ dalvik.system.nativestart.main(native method) 10-09 08:16:21.840: e/androidruntime(1557): caused by: android.view.inflateexception: binary xml file line #2: error inflating class resources 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.createitemfromtag(genericinflater.java:441) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.inflate(genericinflater.java:317) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.inflate(genericinflater.java:263) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.preferencemanager.inflatefromresource(preferencemanager.java:272) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.preferencemanager.setdefaultvalues(preferencemanager.java:485) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.preferencemanager.setdefaultvalues(preferencemanager.java:444) 10-09 08:16:21.840: e/androidruntime(1557): @ com.example.blauzahn.mainactivity.oncreate(mainactivity.java:79) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activity.performcreate(activity.java:5231) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 10-09 08:16:21.840: e/androidruntime(1557): @ android.app.activitythread.performlaunchactivity(activitythread.java:2159) 10-09 08:16:21.840: e/androidruntime(1557): ... 11 more 10-09 08:16:21.840: e/androidruntime(1557): caused by: java.lang.classnotfoundexception: didn't find class "android.preference.resources" on path: dexpathlist[[zip file "/data/app/com.example.blauzahn-1.apk"],nativelibrarydirectories=[/data/app-lib/com.example.blauzahn-1, /system/lib]] 10-09 08:16:21.840: e/androidruntime(1557): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) 10-09 08:16:21.840: e/androidruntime(1557): @ java.lang.classloader.loadclass(classloader.java:497) 10-09 08:16:21.840: e/androidruntime(1557): @ java.lang.classloader.loadclass(classloader.java:457) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.createitem(genericinflater.java:375) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.oncreateitem(genericinflater.java:417) 10-09 08:16:21.840: e/androidruntime(1557): @ android.preference.genericinflater.createitemfromtag(genericinflater.java:428) 10-09 08:16:21.840: e/androidruntime(1557): ... 20 more

for me seems "resources" wrong tag or that. so? tag need?

remove <resources> tag res/xml/defaults.xml

that file should this:

<?xml version="1.0" encoding="utf-8"?>

<preferencecategory android:title="preferencecategory a"> <checkboxpreference android:key="checkbox_preference" android:title="title_checkbox_preference" android:summary="summary_checkbox_preference" /> </preferencecategory> <preferencecategory android:title="preferencecategory b"> <edittextpreference android:key="edittext_preference" android:title="title_edittext_preference" android:summary="summary_edittext_preference" android:dialogtitle="dialog_title_edittext_preference" /> </preferencecategory>

android sharedpreferences android-preferences

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -