I have a different arraylist with column names. I want to have a generatized create method that should create table based on the arraylist i have passed. Is it possible to have a structure with can create table dynamically. Please suggest any solution.
private static class OpenHelper extends SQLiteOpenHelper {
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
System.out.println("openhelper1");
}
@Override
public void onCreate(SQLiteDatabase db) {
Log.d("**DataHelper", "***********in oncreate");
db.execSQL("CREATE TABLE " + TABLE_NAME + " (username TEXT,altnum TEXT,passkey TEXT,flag TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Example", "Upgrading database, this will drop tables and recreate.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
I created my own class to create tables and insert values in generatized manner.