Android SQLite Table not created

后端 未结 5 611
名媛妹妹
名媛妹妹 2021-01-23 18:12

I\'m trying to create a table of statistics but for some reason, it doesn\'t create until I call StatisticsAdapter.insertEntry() for the first time. After that, I c

5条回答
  •  深忆病人
    2021-01-23 18:51

    Have you tried uninstalling the app before running the code? If the previous version of your code created db without statistics table, you have to increment your database version (DatabaseHelper.DATABASE_VERSION) to trigger onUpgrade call, which will create the table.

    The second thing you can try is to extract table name into constant and using it instead hardcoded strings. Maybe you have a typo somewhere?

    I'd also recommend pulling the database from device and checking its schema with command line sqlite client:

    adb shell
    busybox cp data/data/com.your.package/databases/database.db /sdcard
    exit
    adb pull /sdcard/database.db
    sqlite3 database.db
    .schema
    

提交回复
热议问题