I am trying to get writable database using DBFlow using the FlowManager like this FlowManager.getDatabase(SampleDatabase.NAME).getWritableDatabase()
using DBFlow version "4.0.0-beta1"
but i get an error DatabaseWrapper cannot be converted to SQLiteDatabase
. I found an issue on Github Can't use existing SQLite database but i cant understand what it means. I really need to do this will be grateful for any help.
Asked
Active
Viewed 119 times
0

christoandrew
- 437
- 4
- 17
1 Answers
0
This means that the FlowManager.getDatabase(SampleDatabase.NAME).getWritableDatabase()
method does not return a SQLiteDatabase object like SQLiteOpenHelper.getWriteableDatabase()
. Instead, it will return an instance of DatabaseWrapper
class.
If you need direct access to the database, you should be able to get the file path to the database file using FlowManager.getDatabase(SampleDatabase.NAME).getDatabaseFileName()
. Use this path to open your database using the Android API. However, this is definitely not the recommended way of using DBFlow and maybe leads to unexpected behaviour.

NiThDi
- 1,007
- 1
- 9
- 22
-
So what is the recommended way – christoandrew Dec 08 '16 at 07:28
-
Depends on what you are trying to do. All you said was that you need access to a writable database :) – NiThDi Dec 08 '16 at 08:05
-
maybe this can be another solution: `SQLiteDatabase mDb = ((AndroidDatabase) FlowManager.getDatabase(AppDatabase.DB_NAME).getWritableDatabase()).getDatabase();` – 4535992 Mar 15 '17 at 20:28