android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
上のエラーがでた、でもカーソルの項目は1以上

結論、レコードが0件だった!
項目にアクセスする前に件数確認

c = db.query("T_IMAGE_STORY",
    new String[] { "ID" },
    "CATEGORY_ID = ? AND POS = ?",
    new String[] { String.valueOf(categoryId), String.valueOf(pos) }, 
    null, 
    null, "ID");

if(( c != null ) && c.getCount() > 0 ) {
    c.moveToFirst();
    id = c.getSting( 0 );

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha