How to delete SQLite database from Android programmatically

前端 未结 12 1637
猫巷女王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:37

    you can create a file object of current database path and then delete it as we delete file from folder

        File data = Environment.getDataDirectory();
        String currentDBPath = "/data/com.example.demo/databases/" + DATABASE_NAME;
        File currentDB = new File(data, currentDBPath);
        boolean deleted = SQLiteDatabase.deleteDatabase(currentDB);
    

提交回复
热议问题