SQLite rawquery selectionArgs 不起作用 [英] SQLite rawquery selectionArgs not working

查看:26
本文介绍了SQLite rawquery selectionArgs 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了以下原始查询

private static final String DB_QUERY_GETPOS = "select f._id, F.FName, F.FArt, P.VName, O.Gebaeude, O.Raum from Faecher as F " 
                                                     + "inner join profs as P on F.Prof_ID = P._id " 
                                                     + "inner join ort as o on F.ort_id = o._id " 
                                                     + "inner join position as PO on PO.pos=? and id is not null where f._id = PO.id and PO.pos=? order by f._id;";

为什么在访问填充有此查询结果的 Cursor 或 ArrayList 对象时会出现 ArrayOutofBounds 异常?

Why do I get ArrayOutofBounds exceptions when accessing a Cursor or ArrayList Object filled with the result of this query?

为什么 ? 参数不接收我传递给 rawquery 的参数?

Why don't the ? params pick up the args I pass to the rawquery?

推荐答案

在 Android 中使用游标时,请记住在读取数据之前使用 moveToFirst 函数.否则会导致ArrayOutOfBounds异常.

When you work with cursors in Android, remember to use the moveToFirst function before reading the data. Otherwise it will result in ArrayOutOfBounds exceptions.

这篇关于SQLite rawquery selectionArgs 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆