How Do I Create Tables Dynamically in SQLite in Android?

前端 未结 1 1028
醉话见心
醉话见心 2021-01-06 22:14

I am creating an application where a table gets generated in SQLite Database as soon as a new user registers, but I can create tables only in the onCreate() method in the SQ

相关标签:
1条回答
  • 2021-01-06 22:34

    Error show that your table is not created, because you have put semicolon (;) at the end of query so write proper like below, its create runtime when you call this function.

    public void createUserTable(DatabaseOperations d, String user) {
        final SQLiteDatabase db = getWritableDatabase();
        String CREATE_TABLE_NEW_USER = "CREATE TABLE " + user + " (" + UserInfo.NOTES + " TEXT)";
        db.execSQL(CREATE_TABLE_NEW_USER);
        db.close();
    }
    
    0 讨论(0)
提交回复
热议问题