I'm using SQLite in android. I want to drop the database.
For example: mysql- drop database dbname
How do I implement this code in SQLite?
To drop a table in SQLite, use the DROP TABLE statement. Running this statement removes the table from the database. It is completely removed from the database schema and the disk file. Therefore the table can not be recovered.
Like most relational database systems, SQLite does not use the DROP DATABASE command to drop a database and there is no special syntax or steps to drop the database in SQLite. You just have to delete the file manually. Here filename is always unique i.e. database name is always unique and it is case-sensitive.
SQLite stores its databases as a normal file within the computer's file system, so creating and dropping databases is not really applicable. If you need to completely remove a database, you will need to delete the database file from the file system. Then you can navigate to the file in the file system and delete it.
to delete your app database try this:
this.deleteDatabase("databasename.db");
this will delete the database file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With