N
N
noslok2014-03-25 23:00:23
Android
noslok, 2014-03-25 23:00:23

How to organize the storage of settings in the android application?

There are application settings.
There is an activity that allows the user to change settings (for example, select data sources).
The service uses these settings (for example, it accesses the Internet using data sources and downloads something).
How to organize the storage of these settings in the application? It doesn't work in preferences, as it seems to me. The database is too complex a solution for this task.
There is an idea to make a singleton, which is initiated in application by reading settings from a file.
Tell me how to do it.
UPD.
The settings are quite large and are not a simple type and are likely to grow, so I think Serializable is the way to go in this case.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stepan, 2014-03-26
@L3n1n

SQLite to help you..

P
ProkletyiPirat, 2014-03-26
@ProkletyiPirat

I'm solving the exact same problem right now.
now there are only a couple of settings and they are stored in preferences.
at first I thought to implement everything in preferences, but due to grouping and conditions, the size and complexity of changing these preferences will be mega huge.
then I thought about the database, but here again the hemorrhoids in adding / deleting / changing both the settings themselves and their number.
in general, due to the fact that when adding a new "feature" you will have to shovel the code in several places at once (and this is not counting the implementation of the "feature" itself), he abandoned the above ideas.
but not everything is so sad, such an idea came to mind "to store settings in xml or json format". Actually store in the form of text the default settings in preferences, and group settings in the database.
When the settings are needed, they are parsed from the json string to the map and transferred where necessary. As a result, I have the opportunity, without touching saving / loading / transferring data to preferences and the database, to add feature settings, I just need to tweak the deserialization due to nested settings.
if there is no nesting of settings (instead of map, just a set of variables), then at least in gson serialization / deserialization takes place in a couple of lines of code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question