Need some help with SQLite


I want to make an app that’s reading SQLite database into tables. And the problem is; I’ve never done any of those 2 things before! I’ve never created either a table before and I’ve never creater or read an SQLite database.

I always have problems learning new things that I’ve never had any experience with before. Things aren’t usually explained good enough in tutorials and examples. I’d be really really thankful if anyone could take some time and explain these things to me or give me some links that will take me to very detailed tutorials.

  1. How to create an SQLite databse and connect it to Android? Note: I don’t want to create SQLite database in Eclipse (or is there no other way?), I want to create a database file that I’ll later put in Assets folder and read from it.

  2. What’s the easiest way to read from an SQLite databse and manipulate that data to put it in a table.

Some more info on my app to give a better image of what I’m trying to do. I’m trying to make a school scheudele map for my school. There will be scheudeles for every day, for every class and I want to read that data so that it’ll appear as something like this:

What would be the right way to approach this?
Thank you!

Your question is quite vague. Let’s see…

When you say “table”, do you mean a data table within a database, or a table display? For the latter, I would recommend the “TableLayout” layout.

SQLite databases are usually created by the app, and it is tightly associated with the app, on the user’s device. It’s difficult to bundle an actual database in an APK. The usual approach is to have the data in text form as an XML, JSON or plain text file in the /assets folder, and parse and read it into SQLite the first time an app starts up.
Of course it only makes sense to use a database in this case if the app is capturing additional data that you need to persist between multiple user sessions.

When you query a SQLite database with a SELECT statement, you get a Cursor object which you can use to iterate over all the rows and columns. You could either read that directly and populate a TableLayout, or a better way would be to read the data from the cursor into entity objects, and have a separate class the handles the presentation layer and displays those entities in a TableLayout.