Room数据库是否支持实体中的布尔变量? [英] Does Room database support boolean variables in entity?
本文介绍了Room数据库是否支持实体中的布尔变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道sqlite不支持Boolean,我们需要使用int列来模仿Boolean的行为.但是Room是否支持布尔值?如果我的实体中有布尔值怎么办?它会按预期工作吗?
I know that sqlite does not support Boolean and we need to use int columns to mimic the behavior of Boolean . But does Room support Boolean ? What if have a Boolean in my entity ? Will it work as expected?
推荐答案
是的.当您使用room存储布尔值时,它会自动存储1 for true
和0 for false
.
Yes it does. When you store boolean using room, it automatically stores 1 for true
and 0 for false
.
与阅读时的情况相同.它将1或0分别转换为true/false.
And same case while reading. It converts 1 or 0 to true/ false respectively.
这篇关于Room数据库是否支持实体中的布尔变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文