Accessing a Database -- Code Design Question

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Accessing a Database -- Code Design Question

Postby Fretful » Mon Feb 01, 2010 3:18 pm


i am new to accessing the internal sqlite database. Now i got a app where i got multiple tables. I looked at the NotePad example of google but they just access one table. So should i write a DbAdapter for every table? Or should i put it all into one? Or should i do it totally different?

Some of the tables also reference each other. So as example i got a "carmaker" table and a "model" table and the "model" belongs to a "carmaker" - what about such types of queries?
Once Poster
Once Poster
Posts: 1
Joined: Mon Feb 01, 2010 1:02 pm


Postby jwei512 » Tue Feb 02, 2010 7:48 am

The design is up to you and what you have to do with your multiple tables.

In my experience, I've always created a separate content provider for each table that I needed, and for organizational purposes I'd probably shy away from putting them all into one DB adapter. However, if you need two tables to frequently interact with each other, you can override the query() method so that it will return a cursor pointing to the results of the join. If you don't want to do this, you can also write simple wrapper functions that make a db.rawSQL() call with a JOIN query and then return the values that way.

Let me know if you have questions.
- jwei
Examples, Code, and Tutorials
Senior Developer
Senior Developer
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA


Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 2 guests