Saving data on Android for data visualization - android

I'm creating an app where I'm going to be storing data that the user enters. Let's say for instance it's someone weight. I have created an SQLite database that is able to store this information. However, I want the user to be able to update the value if the weight changes, but I don't want to lose the previous data. Would I have to create a separate database to store this past information? Or is there a more effective approach? Thanks for your time.

Related

Store user data in database separately

What is the best practice to store user data separately from the actual app data? The user data is a statistic and it will be collected during app usage. The database must be always updated but I have to keep the user statistic untouched. Can I store for example the statistic on one table? but can I keep this table when the App will be updated?
Update:
Sorry, I think my question was misunderstood. What is the best practice to manage two kinds of Data?
Save all data in one database and save the User-Data in seperetly tables? or
Create two Databases, one for App-data and one for User-data?
I'm not sure exactly of your question, but yes, you can have multiple tables in SQLite. So you can have one table for the user, call it tblUserStatistics and then other tables for the app, or depending on the data, the app information could be stored in preferences.
Yes, you can store your statistics in one table, but it's structure depends on what you want to save. If you want to save only numbers, you can create a table with 2 columns (1st one an ID and the second one the value you want to save), and update your rows when your data changes. If you've got multiple types of data to be saved (numbers, text, dates, whatever), you must create different columns with different data types, but still, you can do it. For your other questions the answer is yes, your table will be kept after you update your app, because it gets saved in a database which doesn't get modified when the user updates the app, just make sure that when you create the new version you don't change the name of the database.

Saving a form after filled in Android

I wanted to know how to create something like this to save information, after a form has been filled out? This is from the App Timetable and I couldnt get any information on how to do this? Any Suggestions/Solutions?
Regards,
Michael
Refer this information on Android Developers website for Storage Options in Android.
You will read if you need to store large amount of data you need to create a Sqlite Database but if you need to save small amount of data then Shared Preferences will do.
Now you need to save and retrieve data from these storage options.
1) Shared Preferences Tutorial
2) Sqlite Database Tutorial
I assume till now you have done with saving and retrieving data . Now you need to match your current time with saved time in your app like a Alarm clock do. For that you need to implement a service that will tell you how much time is left in your task or what is upcoming event.
Tutorial on service.

How to save android text entered by the user?

For my newest app it it one that will save multiple EditTexts where the user can enter stuff.Like say if it was a note app,how would i get them to save?
There are multiple ways to store data on Android. Read about data storage.
In your case you might have multiple text records with some metadata (time when created, etc..), so I'd recommend the database.
Check out how to store preferences with android's "SharedPreferences":
http://www.javacodegeeks.com/2011/01/android-quick-preferences-tutorial.html
This way you can indefinitely store whatever you're working with as a string, object, etc. Also, you can check out how to work with android's SQLite Database, which might be harder to figure out when you start working with it, but it gets easier over time.

How to keep stored data even when an application update is done?

My question is simple :
I have a "flag" stored in SharredPreference but when the user is doing an application update, this data is ereased. Is there a way to keep data stored even if the user is doing an application update ?
Well, as far as I know you have only two choices - write it in a file or save it in the database. I always put the data in the db, from witch they are loaded at program start. Just have a table with the prefs in it and you are sure, that your data is not deleted, even after updating. The database interface is easy to use and lean - therefor I use it.

how much space needed to Store SharedPreference in Android?

I have one Application which has more then 5 Activity I want to know how much space is needed to store 10 different values to SharedPreference. or I have to user Sqlitequery ?
Simple in One Activity I have 4 Field like FirstName,LastName, Age, City when user Click on th button then new Activity is called and in this activity Full Information is Display, so I can do that in two way. First Way I Store all the Information in the SharedPreference and in Second Activity I get this Stored Values and another way is i only store record id and store it in intent.putextra and get it to another activity and Fire Sqlite Query. so I want to know which one is best for Application .(As per Memory Uses and Speed )
If you do not need persistent storage then you can simply pass the data using intents from one activity to another or maybe even keep some static variables in a separate class say Const.java
If you need persistent storage and if your data is limited, I would always recommend using SP over SQLite which should be used for relational data. DB operations take more time and can hit performance besides there is always chance of DB getting corrupted.
Sqllite is a really good solution if you want to be able to add easily more preferences.
It's a bit heavy to set-up but really powerfull.
http://developer.android.com/guide/topics/data/data-storage.html
For me, database is for storing data, and sharedpreference just app config.
Shared preferenses apereas to be the choise here, it is very good to store simple settings and very fast and flexible.
A database would IMO be overkill here :)

Categories

Resources