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

前端 未结 12 2092
栀梦
栀梦 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:19

    I know nothing about the Android SQLite API, but if you're able to talk to it in SQL directly, you can do this:

    create table if not exists mytable (col1 type, col2 type);
    

    Which will ensure that the table is always created and not throw any errors if it already existed.

提交回复
热议问题