Android Question Saving data that is in table form

Hi,

I am a very beginner and did not find a definitive solution in books.

I want users to input data and then save it to a file or database. The data is in a table form. So every day a users inputs variables and these variables must be saved.

Users can later view these variables and change them if needed. I have to do calculations with the data.

The data will be saved like:
Day Temperature Distance Win
1 19 3 Yes
2 20 1 No
3 19 5 Yes
4 15 2 Yes

What will be the best type of variable that i can use and what will be the best form to save the data such that i can easily do calculations? Use a text file or a database? And which one.

It would be nice if i can adress data cells by referring to the colomn and row numbers.

Can you direct me to an example that does save and read data?

Thnx!
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
Use a text file or a database? And which one.
Can you direct me to an example that does save and read data?
Your question is loaded. Think: SQLite database. The best and most popular way to display database table data in a tabular form as of this date is making use of B4XTable. The following link has a a nice simple example by Erel of using B4XTable to display data from a SQLite database.table You can run the example as is to see how they fit together before you even dive into SQLite programming:
https://www.b4x.com/android/forum/threads/b4x-b4xtable-load-data-from-sql-database.102520/#content

As far as learning SQLite there are tons of examples and sample codes in the forum. I would start with downloading klaus’s booklets. One of them treats SQLite CRUD (CREATE, READ, UPDATE, DELETE) in details. If you go to any post by Klaus, you will see a few links under his signature to download the booklets.

Nothing is going to come to you in one thread. It will take you a little bit of time. You have to suffer a little bit like we did. But this is a start. Once, you get a feel of SQLite, you can start posting threads if you get stuck and need help. Many of the forum members love to help and jump on the help band wagon as soon as they see SQLite because of its popularity.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Upvote 0

aeric

Expert
Licensed User
Longtime User
I did not find a definitive solution in books.
You must be reading some wrong books. ? I recommend using the database approach. Reason, there are many functions in SQL you can use e.g Sum(), Count() for your calculation. It is easy to add, edit and delete the data. You can have multiple tables to store your data in a single database file. If you use text file then you may need multiple text files and you need to handle problems such as column separator and data types.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
You can too try this:
or
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Why are we bombarding the OP who just joined the forum with posts. Is it not more advantageous to have him absorb the concept slowly and not drown him with a multitude of posts some of which have duplicate information.
 
Upvote 0
Top