How does one check if a table exists in an Android SQLite database?

前端 未结 12 2091
栀梦
栀梦 2020-11-27 12:37

I have an android app that needs to check if there\'s already a record in the database, and if not, process some things and eventually insert it, and simply read the data fr

12条回答
  •  情深已故
    2020-11-27 13:06

    Important condition is IF NOT EXISTS to check table is already exist or not in database

    like...

    String query = "CREATE TABLE IF NOT EXISTS " + TABLE_PLAYER_PHOTO + "("
                + KEY_PLAYER_ID + " TEXT,"
                + KEY_PLAYER_IMAGE + " TEXT)";
    db.execSQL(query);
    

提交回复
热议问题