Update/alter Android Preferences dynamicaly

by Lars Nielsen Lind » Tue, 04 May 2010 02:36:39 GMT


Sponsored Links
 Hi, I have tried to find a way to update the Android Preferences
dynamically.

Under the /res/xml directory I have placed a XML file with
CheckBoxPreference elements. During application usage some of the
preferences CheckBoxPreference elements may vary in numbers. Sometimes
there may be 10 items and at other times there may be 35.

I have tried to place the XML file in the /assets diectory (where read
and write is possible) and then tried to replace the
R.xml.<XMLFileName> in the
addPreferenceFromResource(R.xml.<XMLFileName>) with the Assets file -
but that won't work.

Is it in anyway possible to write to, during runtime programmatically,
the XML files placed in the /res directory - and if - how do we do
that?

Is it possible - programmatically - to create and delete the entries
in the preferences - thereby omitting the XML file?

Any help is appreciated.

Thanks,

Lars

--



Update/alter Android Preferences dynamicaly

by TreKing » Tue, 04 May 2010 03:58:36 GMT


 On Sat, May 1, 2010 at 4:28 PM, Lars Nielsen Lind <larsnielsenl...@gmail.com




Nope. All /res/ content is read-only.



Sure. You have a PreferenceActivity, I presume? In onCreate() you should be
able to create and all the preferences your heart desires.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. Content Provider General Questions For a Newbie

Hi there,

I am having a hard time understanding content providers.

In the notepad example and others, the content provider never even
declares its CONTENT_URI anywhere inside itself, yet the docs say to
publicly declare this.  It's declared in a different class.  So when
an activity queries a content provider with a CONTENT_URI, how does
Android know which one I want.  I see no link between a content
provider and its CONTENT_URI declared in another class.

I also don't how to think about intents and content providers.  I know
that you don't call an intent on a content provider.  But an activity
queries a content provider without an intent, and an activity has a
mimetype attribute in the manifest that would seem to tie it to a
content provider.

Can someone please help?

-- 

2. cant workout why a NullPointerException occuring !! :0

> E/AndroidRuntime( 682): Caused by: java.lang.NullPointerException

What is happening at/around this line in your file?

--

3. Can't access layout views from inside parent view

4. STATISTICAL COMPONENT

5. mp4,gif,flash animated wallpaper for android 2.1 for HTC nexus one?

6. I don't understand URIMatcher

7. Open all sites that blocked in your country from here