Lucas P.
Lucas P.

Reputation: 4532

Multiple Preferences for single app using AppCompatPreferenceActivity?

I'm making an app that will have a list with multiple devices (let's say that each device is just an IP address string) that the user saved. For each device I need to save some preferences, such as device name that the user sets, if the device is enabled by the user, etc.

I was able to create a SettingsActivity and Android Studio made this extremely easy. The problem is that these settings are global, for the whole app. Is there a way to have separate settings for each one of the user's saved devices? Or I'll have to with the SharedPreferences for each device? It's just that the SettingsActivity is so convenient and everything just works.

Thanks.

Upvotes: 0

Views: 47

Answers (1)

Warrick
Warrick

Reputation: 1963

You will need to use SharedPreferences directly to store the data structures. The scaffolded SettingsActivity is only designed for app global settings.

I would almost be inclined to say you should be using a database, since it sounds like your app allows users to save and read a potentially large amount of data - not something SharedPreferences was designed for.

Upvotes: 1

Related Questions