How to delete SQLite database from Android programmatically

前端 未结 12 1630
猫巷女王i
猫巷女王i 2020-11-27 10:41

I would like to delete the database file from the Android file system programatically? Can I have a shell script launch adb which in turns runs a

12条回答
  •  时光取名叫无心
    2020-11-27 11:27

    I have used the following for "formatting" the database on device after I have changed the structure of the database in assets. I simply uncomment the line in MainActivity when I wanted that the database is read from the assets again. This will reset the device database values and structure to mach with the preoccupied database in assets folder.

        //database initialization. Uncomment to clear the database
        //deleteDatabase("questions.db");
    

    Next, I will implement a button that will run the deleteDatabase so that the user can reset its progress in the game.

提交回复
热议问题