tech74
tech74

Reputation: 301

Storing list of account settings on Android

Just wondering how to do this on Android. My application needs to store a list of the user's accounts. Each account would have, account name username, password, server address etc.

I first tried to implement this with Preference Activity, this worked well but it seems to only result in a user interface for a single account. I am missing how to arrange this so the data is stored for an array of accounts, so if Account 3 is selected from a top level list the Preferences will display the settings for Account 3.

For example if you have an email app with multiple accounts, you want to be able to configure each account individually. They have the same settings, but different instances, so each account would have it's own preference file.

Thanks

Upvotes: 0

Views: 602

Answers (1)

Sergey Benner
Sergey Benner

Reputation: 4431

You will most likely need a database (local sqlite usually) to store the data then you will have you use either the ListView and implement onClick methods OR as you say the PreferenceScreen and add preferences programmatically when you retrieve your data from the database for each account. In order to achieve it take a look here Dynamic ListPreference in android or here How can I keep on adding preferences when i click one?


hope this helps abit

Upvotes: 1

Related Questions