-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database Version Always 0 #49
Comments
Here is Database file @Database(
entities = [SyncEntity::class, BatchEntity::class, SMSEntity::class],
version = 1,
exportSchema = false
)
@TypeConverters(DataSyncSMSConverters::class, DataSyncSMSMetaDataConverters::class)
abstract class DataSyncDatabase : RoomDatabase() {
companion object {
@Volatile
private var INSTANCE: DataSyncDatabase? = null
fun getInstance(context: Context): DataSyncDatabase =
INSTANCE
?: synchronized(this) { INSTANCE ?: buildDatabase(context).also { INSTANCE = it } }
private fun buildDatabase(context: Context): DataSyncDatabase {
System.loadLibrary("sqlcipher")
val password = "Password1!"
val databaseFile = context.getDatabasePath(DATABASE_NAME)
val factory = SupportOpenHelperFactory(
password.toByteArray(StandardCharsets.UTF_8),
null,
true,
1
)
return databaseBuilder(context, DataSyncDatabase::class.java, databaseFile.absolutePath)
.openHelperFactory(factory).build()
}
}
abstract fun dataSyncSmsDao(): DataSyncSMSDao
|
Update: Issue ResolvedThe problem was caused by the database filename. I was initially using Suggestion:It would be helpful if the repository could handle this scenario or provide a warning when certain filename extensions cause issues with version tracking. This would prevent similar issues for other users. |
I am happy to hear that you were able to resolve the issue. Have you confirmed this behavior without SQLCipher for Android, but with the Room API? SQLCipher for Android does not prevent the |
Issue: Database Version Always 0
Description:
I am encountering an issue where the database version is always returned as 0. This results in the database being recreated every time the app is reopened, leading to data loss.
The
getVersion()
function is used as shown below:The text was updated successfully, but these errors were encountered: