How can I clear an SQLite database each time I start my application?

前端 未结 4 1685
不知归路
不知归路 2020-12-06 03:16

I want my SQLite database instance to be wiped away when the program starts.

What I tried was make a method on my class MyDBAdapter.java like this:

p         


        
4条回答
  •  渐次进展
    2020-12-06 03:59

    There is a method you can use to tell SQLiteDatabase to delete one of the databases programatically like this:

    context.deleteDatabase(DATABASE_NAME);
    

    You need the Context and the name of your database to delete.

    You could stick this in your constructor that makes the connection to the SQLite Database.

    More info: how to drop database in sqlite?

提交回复
热议问题