Android: Rename database filename?

957 Views Asked by At

I have an existing database with the app name without ".db" extension at the end. Now the database created with DBFlow library adds ".db" extension at the end. How can specify that it shouldn't add the ".db" extension when creating database.
Or
If It can't do that then please tell me a way so that I can rename my existing database to have a ".db" extension before DBFlow creates the database.

Thanks in advance.

1

There are 1 best solutions below

0
On

I tried following code and it worked.

File dbFile = getDatabasePath("db_name");
boolean renamed = dbFile.renameTo(new File(getDatabasePath("db_name").getParent(), "db_name.db"));
Log.d("Renamed", renamed+"");

Logcat outputs true And I checked by using adb shell and it did work. If there is someother way to do it please add it.