Fixed
Status Update
Comments
yb...@google.com <yb...@google.com>
fa...@gmail.com <fa...@gmail.com> #2
do you want to drop all tables or truncate all tables?
i think we can generate a method that does that in RoomDatabase.
i think we can generate a method that does that in RoomDatabase.
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #3
I was also looking for this and could not find it. For me it would be ideal if it could drop the whole database. So when the user logs out everything is cleared and the new database is then created on a new log in - the same as if running the application for the first time.
yb...@google.com <yb...@google.com>
sh...@google.com <sh...@google.com>
sh...@google.com <sh...@google.com> #4
you can consider closing and then deleting the database. (context.deleteDatabase).
The only difference vs truncating would be the auto-increment ids would be reset. Is it that important?
The only difference vs truncating would be the auto-increment ids would be reset. Is it that important?
sh...@google.com <sh...@google.com>
yb...@google.com <yb...@google.com> #5
I was looking for something like deleteDatabase in the documentation and could not find it. That would be perfect for me. I don't care about auto-increment ids resetting or not, but lets wait for the original poster to tell his/her wishes.
yb...@google.com <yb...@google.com>
va...@gmail.com <va...@gmail.com> #6
Truncate makes more sense because my goal is to get rid of all the data on logout, although both options drop or truncate would work. I don't care much if tables are dropped neither about auto-increment ids resetting. In terms of performance which option is better?
ms...@gmail.com <ms...@gmail.com> #7
You could also use `deleteDatabase(DB_NAME)` in your Activity where user is performing logout. This will delete the entire database.
PS: Make sure the DB_NAME is the same name passed to Room.
PS: Make sure the DB_NAME is the same name passed to Room.
Description
Version used: 1.0.0-alpha9
Devices/Android versions reproduced on: Android 5 (it works on Android 8)
I have a strange problem connected to a MutableLiveData that doesn't trigger the observer when updated in onActivityResult. The cause seems to be a wrong state in LifecycleRegistry, in the following example the println in onResume prints "resume CREATED". Between startActivityForResult and onResume the state is set to CREATED even if the Activity remains always started (because the other activity is not full screen).
You can reproduce this issue using this Activity:
class LiveDataTestActivity : AppCompatActivity(), LifecycleRegistryOwner {
private val lifecycle = LifecycleRegistry(this)
override fun getLifecycle() = lifecycle
private val myLiveData = MutableLiveData<Int>().apply { value = 0 }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val textView = TextView(this).apply {
text = "AAAA"
setOnClickListener {
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
type = "text/plain"
}
startActivityForResult(sendIntent, 123)
}
}
setContentView(textView)
myLiveData.observe(this, Observer<Int> {
textView.text = it.toString()
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
myLiveData.value = (myLiveData.value ?: 0) + 1
println("Value ${myLiveData.value}")
}
override fun onResume() {
super.onResume()
println("resume ${lifecycle.currentState}")
}
}