Take the 2-minute tour ×

i want to make that every time i add a new row to a database that have only one column "name" there will be a creation of a new table with that name, i can't do it, i get really confused with the whole database version idea.

i tried to change the version manually but after i close the app it gets back to the first version and deletes all the information stored in there, i even tried to create 2 different databases one for the table with the names and one for the tables and i could not make it work too...

share|improve this question
i forgot to mention... i have a list that is being displayed in the main activity the list contains all the names from the name table so i cant change its version or it will be deleted –  user1375265 Jul 28 '12 at 13:38
Are you sure you really need to create a new table each time you insert a new row? This is a really bad design which can usually be avoided easily with the use of foreign keys. –  Dalmas Jul 28 '12 at 13:48
i want to create a shopping app that will have some shopping lists each containing some products... so every time you create a new list i insert its name to the name table and create a new table for its products –  user1375265 Jul 28 '12 at 13:50
add comment

1 Answer

Creating a table each time you insert a row is a bad design and can be done in a more efficient way.

A better idea is to create two tables. The first one will have 2 columns : one with the "name", and the other will contain an unique identifier (ID) of this shopping list which refers to one or multiple rows in the second table (each product).

So the second table will contain an ID column and other columns to store additional data about each product added to the list. This is where you can link your tables without creating a new table for each row.

Just create new rows in your second table with the ID of a particular shopping list, then with the right SQL query you can easily get a specific shopping list with its products.

share|improve this answer
ill give it a try! thanks for the idea –  user1375265 Jul 28 '12 at 13:56
add comment

Your Answer


