2

My application is communicating with a database (reading only, stored in the assets file) in such a way that the user can display list of content from this database. For example, a few thousands elements can be displayed from this database in a listview, user can click on any element and get more information.

I would like to add a new function which would allow the user to create a "favorite" list. So, every time the user would click on an element from the database, he could click a button "add to favorites", and then from the main menu there would be a button "Favorites" opening a listview with only the elements the user decided to add in the first place.

I already have a DatabaseHelper class extending SQLiteOpenHelper, and a DatabaseAdapter class specifying the interactions with my first table.

From what I have understood, I can keep one database (and re-use my DatabaseHelper class then) and create a new DatabaseAdapter2 class defining the method for the new table (add new element, delete element, etc.) as well as the fields of my table. Is it right? I'm not so sure because my DatabaseHelper is defined in "read only" to protect my main table from any modification, but the second table should have to be in "write+read" so maybe it would be better to have a second databaseHelper? It might be a trivial question but I can't find much information about creating a new table/database from an existing one.

1 Answer 1

1

The way you are describing your app, I would consider making it all as one database, even though it would require you to open your mainTable to writing. If you are reading from your favorites database, then pulling subsequent data from your mainTable database it will be much slower than if you are making complex queries pulling from both tables from one database.

3
  • I don't mean to imply that all apps should have only one database, only that a table that is a list of favorites from one database would make sense to be a part of that database.
    – HalR
    Apr 10, 2013 at 4:32
  • Thanks for your answer. So as you suggested, I am gonna keep one database and simply add a new table. I have created my new table now, with all the fields I wanna keep. As my databaseHelper class was defined as a "read only" access to my db, is changing it to a "write and read" gonna put my main table in danger? This table contains lots of information and it should be modified under no circumstances...! Thanks!
    – Phalanx
    Apr 10, 2013 at 7:23
  • There is always a danger if you have your database writeable that you can change something. But its not going to change unless you make writes to that table. We have 100's of thousands of users on our databases and in a few years and have been successfully maintaining things this way.
    – HalR
    Apr 10, 2013 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.