I designed my application to save login data in SQLite database but I want to remove the hole tables and data when the user log out from the application
Asked
Active
Viewed 2,599 times
1 Answers
2
Use DROP TABLE:
// query to obtain the names of all tables in your database
Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);
List<String> tables = new ArrayList<>();
// iterate over the result set, adding every table name to a list
while (c.moveToNext()) {
tables.add(c.getString(0));
}
// call DROP TABLE on every table name
for (String table : tables) {
String dropQuery = "DROP TABLE IF EXISTS " + table;
db.execSQL(dropQuery);
}
Hope it will help you
Milad Bahmanabadi
- 1,047
- 11
- 23
-
it works, thank you bro – Ahmed M. Abdalla Oct 06 '18 at 08:07