Closed guillermolc closed 3 years ago
@guillermo-lagos, It's not possible with current implementation, the method was deleted to avoid issues with spatialite functions, the database that you are importing is a spatialite db?
Approach to deal the issue: 1- Create migrations to insert all data that you want. 2- Modify the library, (I would like to know more about your problem before add that method.)
I am in the same/similar position as @guillermo-lagos . I have a pre-populated Spatialite database that I want to include in the app's assets and be able to open it in the app from there. At the moment, the database contains about 5,5k polygons and weighs just under 50 MB, which basically forbids the migrations approach.
In my case, the database will be read-only, though, so really all I need is to call the createFromAsset()
and I should be able use it as a regular Room database (if my understanding is correct).
So far the only solution I have found is to copy the file directly to the database directory of my app and then load the instance, to make use of it
val instance = SpatiaRoom.databaseBuilder(
context.applicationContext,
AppDatabase::class.java,
DB_NAME
).createFromAsset("my_template.db")
.build()
@guillermo-lagos and @mrclayman thanks for testing, the feature will be available on version: 0.1.1
Good morning, I am using the library, but I had to make some changes in the SpatiaBuilder.kt class, since I need to load a database from the assets folder, but from what I see I do not incorporate this function.
So the change I made was to pass in the instance the name of the file in assets and set it in
class SpBuilder<T : RoomDatabase?> ( context: Context, klass: Class,
name: String,
nameDbAsset: String < ------- HERE
): SpRoom.Builder {
}
I hope you can make the change, greetings.