@Database(entities = [TextEntity::class], version = 1)
abstract class TextDatabase : RoomDatabase() {
abstract fun textDao() : TextDao
companion object {
@Volatile
private var INSTANCE : TextDatabase? = null
fun getDatabase(
context : Context
) : TextDatabase {
return INSTANCE ?:synchronized(this){
val instance = Room.databaseBuilder(
context.applicationContext,
TextDatabase::class.java,
"text_database_1"
)
.fallbackToDestructiveMigration()
.build()
// val factory = SupportFactory(SQLiteDatabase.getBytes("PassPhrase".toCharArray()))
//
// val instance = Room.databaseBuilder(
// context.applicationContext,
// TextDatabase::class.java,
// "text_database_2"
// )
// .openHelperFactory(factory)
// .fallbackToDestructiveMigration()
// .build()
INSTANCE = instance
instance
}
}
}
}
- 참조
https://github.com/sqlcipher/android-database-sqlcipher
https://sonique6784.medium.com/protect-your-room-database-with-sqlcipher-on-android-78e0681be687
'Android(Kotlin)' 카테고리의 다른 글
Android BOOT_COMPLETED (0) | 2022.10.20 |
---|---|
Simple ForegroundService (0) | 2022.10.15 |
Android AlarmManager (0) | 2022.09.16 |
bottomNavigationView (0) | 2022.08.30 |
ViewModelFactory 오류 (0) | 2022.08.19 |