即使android

时间:2015-05-28 23:34:54

标签: android sqlite

我正在使用以下内容从我的表中获取字符串。即使我在数据库中有数据,光标也总是返回空。查询错了吗?

public void find(String myNumber){
 String[] thecolumns = new String[]{
            ID,
            FLAG};

cursor = sqlDb.query(MY_TABLE,
            thecolumns, NUMBER + "='"
                    + myNumber+ "'", null, null, null, null);

 if (cursorToFetchAssets != null   ) {

        cursorToFetchAssets.moveToFirst();{
        try{
            //code to fetch

         }catch{
         //return when there are no rows found. 

     }
 }

编辑:NUMBER的类型为字符串“... + NUMBER +”TEXT,..“而myNumber也是一个字符串

2 个答案:

答案 0 :(得分:0)

修复:问题发生在我的代码的服务器端。不在这里..

答案 1 :(得分:-1)

试试这个:

cursor = sqlDb.query(
        MY_TABLE,
        thecolumns, 
        NUMBER + "=?", 
        new String[]{String.valueOf(number)}, 
        null, null, null);