Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使在Android sqlite中不为null,也返回null_Android_Android Sqlite - Fatal编程技术网

即使在Android sqlite中不为null,也返回null

即使在Android sqlite中不为null,也返回null,android,android-sqlite,Android,Android Sqlite,当数据出现在sqlite中的位置时,我得到了一个空值 Cursor c = db.query("SELECT * FROM table WHERE id " = '" + value + "'", null); if(c !=null && c.moveToFirst()) { temp = c.getString(c.getColumnIndex(b1)); Log.v(TAG, ""+temp); } 日志文件是 ------------ Tag

当数据出现在sqlite中的位置时,我得到了一个空值

Cursor c = db.query("SELECT * FROM table WHERE id " = '" + value + "'", null);

if(c !=null && c.moveToFirst())
{
     temp = c.getString(c.getColumnIndex(b1));

     Log.v(TAG, ""+temp);
}
日志文件是

------------
Tag   Text
-------------
class null 

------------- 
该值存在,但我得到null,因此无法对其进行排序

如果游标为null,显然应该跳过if语句,但它会执行该语句

对于其他一些值,我得到了答案

Tag    Text
-----------
class  100
----------
class  86

感谢您提供的时间和回复

您没有编写正确的
SQL
query
这是正确的查询

Cursor c = db.rawQuery("SELECT * FROM "+ table +" WHERE id  = " + value , null);
您还可以像这样使用
db.query()
方法

    Cursor cursor = db.query(TABLE_NAME, // a. table
            COLUMNS, // b. column names as array of strings

            KEY_ID + "= ?", // c. selections

            new String[] { String.valueOf(id) }, // d. selections args
            null, // e. group by
            null, // f. having
            null, // g. order by
            null); // h. limit

    // 3. if we got results get the first one
    if (cursor != null)
        cursor.moveToFirst();

    temp = cursor.getString(c.getColumnIndex(b1));

在这种情况下,列的值不能为null吗?请进行调试!使用断点!查看光标中有哪些数据!这个问题写得很对,他说它是有效的!感谢大家的回复,使用相同的查询,我在日志文件中得到了问题中提到的其他结果。然而,我尝试了另一种查询方式,如字符串sql=“”;字符串=。。。。。。;SqliteDatabase db=-----;游标c=db.query(…);那就行了