【问题标题】:Does cursor.getString() coerce an int into a string?cursor.getString() 是否将 int 强制转换为字符串?
【发布时间】:2013-03-25 13:10:46
【问题描述】:

文档说:

结果以及此方法在执行时是否抛出异常 列值为 null 或列类型不是字符串类型 实现定义。

他们在谈论哪种实现? sqlite的版本?会打电话的

cursor.getString(INT_COLUMN)

int 值强制转换为String

【问题讨论】:

    标签: android sqlite android-cursor


    【解决方案1】:

    cursor.getString() 是否将 int 强制转换为字符串?

    是的,只要有意义,可以使用getString()getInt()getLong() 等返回表中的相同数据。例如,

    • 如果列数据为 42:getInt() 返回 42,getString() 返回“42”。
    • 如果列数据是植物:getString()返回“植物”,getInt()返回0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      • 2011-11-28
      • 1970-01-01
      • 2013-11-12
      • 2012-05-26
      • 2011-10-02
      相关资源
      最近更新 更多