3

Android を使用して SQLite データベースから null 値を取得できません。

私のデータベースには 10 列あります。1 列目から 8 列目まですべて値が入力されています。ただし、9 列目と 10 列目の値が null または何らかの数値である行がいくつかあります。

確認したい:

String selectQuery = "SELECT * FROM products WHERE barcodeId='" + id + "'";

Cursor myCursor = db.rawQuery(selectQuery, null);
if (myCursor.moveToFirst()) {

    //checking to see if there is something in column 9
    if(myCursor.getString(8) != null){
        // do soemthing
    }else {
        // if there is nothing do something
    }

    //checking to see if there is something in column 10
    if(myCursor.getString(9) != null){
        // do soemthing
    }else {
        // if there is nothing do something
    }
}

私のテーブルの列9と10を使用して、私の例に従って作業コードを提供できますか。

簡単な説明も歓迎します。ありがとう

4

2 に答える 2

3

私の問題を解決してくれたDavidCAdamsに感謝します。

誰かがそれに興味を持っているなら、これが私のコードです。

if(myCursor.isNull(8)){
    Log.w("No value", "Cell is empty");
}else{
    Log.w("Value is present", "There is a value");
}   

if(myCursor.isNull(9)){
    Log.w("No value", "Cell is empty");
}else{
    Log.w("Value is present", "There is a value");
}
于 2014-02-15T22:37:34.437 に答える