Actually I have more than a question. If I uninstall an app, the room database also removed. I debugged and checked using File(getDatabasePath("MyInfoDatabase.db").absolutePath).exists()
before instantiating a room database. Let's say my app crashed and I uninstalled it and then reinstall the app. So it is not possible to get the old room data.
Room.databaseBuilder(appContext, AppDatabase.class, "Sample.db")
.createFromFile(File("mypath"))
.build()
If I am not wrong, then I can copy and save the database to a directory and get the old databack while reinstalling using the above method. Is this the right approach? In this approach getExternalStoragePublicDirectory
is deprecated now. Should I use MediaStore
api for database backup? On the other hand here, it says that room data exists even after uninstalling. Is the room database exists even after uninstalling an app? AFAIK it doesn't exists.