Database to create a database

2010-12-21T18:31:28

I'm using Sqlite with android to develop and app which can be customizable (for the dev) in the future. I have created a database with the data which is then to be used to create the database for the application. So if any changes need to be made in the future or I write an app for somebody else in the future then all I have to do is change this original database. The idea behind this is the dev's database will set up all the UI and everything to do with the app.

I am stuck on what to do next I have the database I need in the app as the dev fully populated. My idea was to create another DBHelper class and within that reference the original DBHelper class and query within the new DB Class. So this is the second DBHelper class that i'm trying to create a database from a previous database:

public class appDbHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "library.db"; //database name   
    Cursor all, tables, options, ui_type;
    SQLiteDatabase database;

    public appDbHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
        DBHandler databaseHelper = new DBHandler(context);
        database = databaseHelper.getReadableDatabase();
        all = database.rawQuery("SELECT * FROM config", null);
        tables = database.rawQuery("SELECT * FROM table_names", null);
        options = database.rawQuery("SELECT * FROM options", null);
        ui_type = database.rawQuery("SELECT * FROM ui_type", null);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        for(int i=0; i<tables.getCount(); i++){
            tables.moveToPosition(i+1);
            String sql = "";
            for(int j = 0; i < all.getCount(); j++){
                if (all.moveToFirst()) {
                    do{
                        sql = ", " + all.getString(2) + " " + all.getString(5).toUpperCase();
                    }
                    while (all.moveToNext());
                }
            } 
            Log.v("DatabaseSQL", sql);
            database.execSQL( "CREATE TABLE " + tables.getString(1) + "(_id INTEGER PRIMARY KEY AUTOINCREMENT"+sql+");");
        }
    }

But I have a feeling this is not the way to go about what I need to do. Any help will be greatly appreciated.

Copyright License:
Author:「SamRowley」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/4498325/database-to-create-a-database

About “Database to create a database” questions

I'm using Sqlite with android to develop and app which can be customizable (for the dev) in the future. I have created a database with the data which is then to be used to create the database for the
I'm new to SQL Server, and I'm asking if can I create a database in other database like this: mydatabase1[database] -&gt; mydatabase2[database] -&gt; mytable[table]
I'm trying to create databases on the fly in Firebase realtime database. I'm using the REST resources: https://firebase.google.com/docs/reference/rest/database/database-management/rest/v1beta/proje...
I have an application that uses hibernate and JPA to handle the database. I know that hibernate can create the database tables for me, however, I've found that I must first create the database file...
I have to create new database (from database files .mdf, .ldf) on Azure (portal.azure.com) programmatically (when new client request it). What is best practice to do this? Do I have to store data...
When I run mysql as root and run SHOW DATABASES; it shows that I have a one_db database, but when I run DROP DATABASE one_db; it outputs the following error: ERROR 1008 (HY000): Can't drop database '
I have any file with database name each line (database.txt): database1 database2 ..... How can I use this file to : $create database $mysqldump $drop database create database from database.txt $
-------This is my Database activity here i m creating database ---------- public void Database_Create(){ try{ db = openOrCreateDatabase(Environment.getExternalStorageDirecto...
I've tried to implement this code and terminal throws error something like this stucked in it As I've applied this code but it throws the error "Access denied for user ''@'localhost' to database 'm...
I have to create database with four table witch one ( nammed table_file) has foreign key from the other tables, first I try to create all tables at the same time but the table_file gives me errors

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.