【问题标题】:Using int value in selection args argument of sqlite for android在 android 的 sqlite 的选择 args 参数中使用 int 值
【发布时间】:2013-07-05 05:56:05
【问题描述】:

这是在使用 Integer.toString() 之前将 int 转换为字符串的正确方法吗?还有其他不需要转换的方法吗?

例子:

 int value = 10;
 Cursor cursor = database.query(
    "TABLE_X", 
    new String[] { "COLUMN_A", "COLUMN_B" },
    "COLUMN_C = ?",
    new String[] { Integer.toString(value) },
    null,
    null,
    null);

【问题讨论】:

标签: android database sqlite


【解决方案1】:

是的,您可以使用以下方式将int转换为String

int i=10;
String[] str = new String[]{String.valueOf(i)};
String[] str1 = new String[]{Integer.toString(i)};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-18
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多