在为Android源码的选择参数args使用int值 [英] Using int value in selection args argument of sqlite for android

查看:131
本文介绍了在为Android源码的选择参数args使用int值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个int转换为字符串使用前Integer.toString的正确方法是()?是否有另一种方式来做到这一点的地方,不需要转换?

例如:

  int值= 10;
 光标光标= database.query(
    TABLE_X
    新的String [] {COLUMN_A,COLUMN_B},
    COLUMN_C =?,
    新的String [] {Integer.toString(值)},
    空值,
    空值,
    空值);


解决方案

是的,你可以使用下面的方法来 INT 转换为字符串

  INT I = 10;
的String []海峡=新的String [] {将String.valueOf(I)};
的String [] = STR1新的String [] {Integer.toString(I)};

Is this the correct way to convert an int into a string before use with Integer.toString()? Is there another way to do this where conversion is not required?

Example:

 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);

解决方案

Yes, you can use the following ways to convert int to String.

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

这篇关于在为Android源码的选择参数args使用int值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆