anboralabs / spatia-room

Implementation of spatia lite database to android component Room
MIT License
41 stars 4 forks source link

The database path cannot be modified #23

Closed wingkingbobo closed 1 year ago

wingkingbobo commented 2 years ago

To specify the database file path, I override Context.getDatabasePath(). But SpatiaBuilder used 'context.applicationContext'. Can it use context directly?

class SpatiaBuilder<T : RoomDatabase?> (
    context: Context,
    klass: Class<T>,
    name: String
): SpatiaRoom.Builder<T> {

    private val roomBuilder = Room.databaseBuilder(
        context.applicationContext,
        klass,
        name
    ).createFromAsset(templateDb)
        .openHelperFactory(SpatiaHelperFactory())
}
dalgarins commented 2 years ago

@wingkingbobo maybe this fit to you: https://stackoverflow.com/questions/48645801/how-can-i-change-the-default-location-of-a-room-database

dalgarins commented 1 year ago

This issue is not part of spatiaroom, change your implementation because that's is the reason why you can't change the database location.