Question

Someone know here, I'm a newbie for android development. Now I'm trying to create a simple fitness application. The first thing is my app will do is getting some data from user. For example; weight, height, age etc. And Program will return something that can change by data what we got from user. I wonder, how do need I storage the data? Need I use PreferenceActivity, database or another?

Also I want to ask, do we need to use term of preference as suffix for layout elements when create layout to use for PreferenceActivity?

Was it helpful?

Solution

How many users do you support in your app on one device? If just one, go for shared preferences: it's easy to use and you store very little data.

If you support multiple users, you may start thinking about a SQLite database. Also, think whether you want to expand your app in the future and maybe add some fitness goals, track weight progress over time, etc. In this case, you may want to use a database as it is much easier to expand.

As for your second question, if you use PreferenceActivity, you don't need a layout at all. You define all preferences in xml file. Check this link for more info: http://developer.android.com/guide/topics/ui/settings.html

OTHER TIPS

Just take sharedPreferences for this little amount of data

If you need to save only that kind of data I suggest you to use sharedPreference (here a nice tutorial http://www.vogella.com/articles/AndroidFileBasedPersistence/article.html).

Then, if you need to save some history, I suggest you to create a database, Android use SQlite (http://www.vogella.com/articles/AndroidSQLite/article.html).

No, you don't need to use your preference name as a suffix for layout elements, but could be useful for you to use similar name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top