Can I paste the password in the Room database like sqlite cipher in android?

823 views Asked by At
@Database(
entities = [WeekDays::class],
version = 1

) abstract class AppDatabase : RoomDatabase() { abstract fun raspisanyDao(): RaspisanyDao

companion object {
    @Volatile
    private var myRoomInstance: AppDatabase? = null

    internal fun getDatabase(context: Context): AppDatabase? {
        if (myRoomInstance == null) {
            synchronized(AppDatabase::class.java) {
                if (myRoomInstance == null) {
                    myRoomInstance = Room.databaseBuilder(
                        context.applicationContext,
                        AppDatabase::class.java, "app_db"
                    ).build()
                }
            }
        }

        return myRoomInstance
    }
}

}

1

There are 1 answers

0
ueen On

You might want to take a look at this library https://github.com/commonsguy/cwac-saferoom

But keep in mind, that a SQL Database and can always be accessed through root and if the encryption is happening on the device can easily be decrypted, so you really shouldn't save passwords locally, think about checking the password on the server and sending a token to the user, that you can save locally to verify the user.