开发者

this function in android seems not working, can anybody give me a explaination?

public long getDoneLength(int mixId, long startPos) {
    SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
    long doneLength = 0;
    Cursor cursor = db.rawQuery("select doneLength from fragment where mixId=? and startPos=?", new String[]{String.valueOf(mixId), String.开发者_高级运维valueOf(startPos)});
    while (cursor.moveToFirst()) {
        doneLength = cursor.getLong(0);
    }
    cursor.close();
    return doneLength;
}


This looks like an infinite loop. You should do if (cursor.moveToNext()) {...}, not while.


cursor.moveToFirst should only be called once. If you wanna know if the cursor is empty use

cursor.isAfterLast() 

Regards, Stéphane

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜