Pablo
01/22/2025, 7:31 PMbus.db, bus.db.lck, bus.db-shm and bus.db-wal
If I open the .db
file with a sqlite browser on that folder (with these other 3 files present) it is correct and has all the data, but if I copy the .db
alone into another folder, then, when I open it with an sqlite browser, it doesn't have all the data, a lot of rows are missing on a table with 26.000 rows. If I copy the other 3 files too, and open the .db
file with the sqlite browser, then the sqlite browser sees all the data. Can someone explain me why this happens and how to solve it? I need to export my .db
file so I need that when I copy it it haves all the data without depending on other 3 files.
How I create the database:
fun createDatabaseBuilder(): RoomDatabase.Builder<BusStopsDatabase> {
val dbFile = File(Util.getAppDataPath()+"data/database/bus.db")
return Room.databaseBuilder<BusStopsDatabase>(name = dbFile.absolutePath)
}
fun RoomDatabase.Builder<BusStopsDatabase>.getRoomDatabase(): BusStopsDatabase {
return this
.fallbackToDestructiveMigration(dropAllTables = true)
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
.build()
}
ephemient
01/22/2025, 9:06 PMephemient
01/22/2025, 9:07 PMPablo
01/22/2025, 10:12 PMephemient
01/23/2025, 4:35 AMephemient
01/23/2025, 4:36 AMdatabase.openHelper.writableDatabase.execSql("VACUUM INTO ?", arrayOf(file.path))
Pablo
01/23/2025, 9:25 AMPablo
01/23/2025, 10:15 AMephemient
01/23/2025, 10:21 AMPablo
01/23/2025, 10:28 AMPablo
01/23/2025, 10:28 AMPablo
01/23/2025, 10:28 AMPablo
01/23/2025, 10:29 AMThe *android.arch* Architecture Components packages are no longer maintained. They have been superseded by the corresponding androidx.* packages. See androidx.room.RoomDatabase instead.
Pablo
01/23/2025, 10:29 AMPablo
01/23/2025, 10:29 AMephemient
01/23/2025, 10:30 AMephemient
01/23/2025, 10:31 AMPablo
01/23/2025, 10:54 AMPablo
01/23/2025, 10:54 AMephemient
01/23/2025, 10:55 AMPablo
01/23/2025, 11:08 AMPablo
01/23/2025, 11:09 AMandroidx-room = "2.7.0-alpha11"
Pablo
01/23/2025, 11:09 AMPablo
01/23/2025, 11:09 AMuseWritableConnection
to solve this?ephemient
01/23/2025, 11:21 AMdatabase.useWriterConnection { connection ->
connection.usePrepared("VACUUM INTO ?") { statement ->
statement.bindText(1, "path")
while (statement.step()) {}
}
}
Pablo
01/23/2025, 12:25 PMPablo
01/23/2025, 12:25 PMPablo
01/23/2025, 12:25 PMephemient
01/23/2025, 12:25 PMPablo
01/23/2025, 12:26 PMPablo
01/23/2025, 12:26 PMPablo
01/23/2025, 12:26 PMPablo
01/23/2025, 12:26 PMdatabase.openHelper.writableDatabase.execSql("VACUUM INTO ?", arrayOf(file.path))
Pablo
01/23/2025, 12:27 PMPablo
01/23/2025, 12:34 PMPablo
01/23/2025, 12:34 PMException in thread "DefaultDispatcher-worker-10" androidx.sqlite.SQLiteException: Error code: 1, message: output file already exists
Pablo
01/23/2025, 12:35 PMPablo
01/23/2025, 12:35 PMephemient
01/23/2025, 12:35 PMPablo
01/23/2025, 12:42 PMPablo
01/23/2025, 12:42 PMPablo
01/23/2025, 12:43 PM