Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop an ORMLite database?

I would like to know how to drop a database with ORMLite. Is there already any API call?

Just dropping all the tables does not delete the whole database.

Thanks in advance.

like image 573
Lara Avatar asked Aug 22 '12 11:08

Lara


1 Answers

Edit:

Looks like you figured it out. You do something like:

boolean success =
    context.deleteDatabase(
        "/data/data/source.package.goes.here/databases/database-name.db‌​");

Edit:

Dropping a database is strange with ORMLite but I think it can be done. Really, when you do a dao.executeRaw(...) method, you have a connection open to the database engine that can perform just about any operation. You should be able to something like:

fooDao.executeRaw("drop database foo;");

That at least works for me under MySQL and it should under Sqlite.


Yes, ORMLite has the TableUtils class which allows you to create and drop tables. Here are the javadocs for the method.

like image 124
Gray Avatar answered Nov 15 '22 13:11

Gray