Android自定义表视图的SQLite(SQL视图,而非Android视图)不一致?

Android自定义表视图的SQLite(SQL视图,而非Android视图)不一致?,sql,android,sqlite,Sql,Android,Sqlite,我在SQLite数据库中为Android应用程序创建了一个自定义视图。 我在Ubuntu上使用Sqliteman测试我的SQL语句,然后再将它们放入我的应用程序中。 我正在尝试对我的视图执行一个简单的select语句。 select语句在SQLiteman中运行良好,但当我将同一语句放入代码时,它会抛出一个错误 声明: select * from item_view where parent_item_id = 0; 视图(作为字符串转换为Java): 错误: 07-16 14:21:15.1

我在SQLite数据库中为Android应用程序创建了一个自定义视图。
我在Ubuntu上使用Sqliteman测试我的SQL语句,然后再将它们放入我的应用程序中。
我正在尝试对我的视图执行一个简单的select语句。
select语句在SQLiteman中运行良好,但当我将同一语句放入代码时,它会抛出一个错误

声明:

select * from item_view where parent_item_id = 0;
视图(作为字符串转换为Java):

错误:

07-16 14:21:15.153: ERROR/AndroidRuntime(5054): Caused by: android.database.sqlite.SQLiteException: no such column: parent_item_id: , while compiling: SELECT * FROM item_view WHERE parent_item_id = 0
我首先尝试在select语句中调用字段item.parent\u item\u id,但没有成功。
然后我拉取数据库并用Sqliteman打开它。
字段按原始表中的方式列出(_id、状态、名称等)
因此,我在Sqliteman中运行了上面的SQL,并能够检索到适当的数据,没有问题,但我无法让它在我的应用程序中运行。
我还注意到,作为DROP TABLE命令删除视图在SQLiteman中有效,但在我的应用程序中无效。
我想知道我是否缺少一些其他视图特定的功能。
不过,我在android文档或任何SQL文档中都没有看到任何内容


从技术上讲,我可以使用原始表进行更复杂的SQL调用,但我的所有表都遵循某些准则,因此我可以动态生成SQL调用。我希望视图表能够保持代码的一致性,并始终重复使用相同的调用,以避免重复代码带来的维护和其他问题。

事实证明,您需要对创建的每个字段进行专门命名,以便android可以将其视为常规表。 解决方案

"create view if not exists item_view as select " +
    "item._id as _id, item.status as item_status, item.name as item_name, item.position as item_position, " +
    "item.parent_item_id as item_parent_item_id, item.note_id as item_note_id, item.other_id as item_other_id, " + 
    "note.contents as note_contents, other.priority as other_priority " +
"from item, note, other where item.note_id = note._id and item.other_id = other._id"

我不能强调你帮了我多少忙!两个小时来,我一直在梳理我的头发,试图找出为什么该死的安卓找不到缺席存在的专栏!
"create view if not exists item_view as select " +
    "item._id as _id, item.status as item_status, item.name as item_name, item.position as item_position, " +
    "item.parent_item_id as item_parent_item_id, item.note_id as item_note_id, item.other_id as item_other_id, " + 
    "note.contents as note_contents, other.priority as other_priority " +
"from item, note, other where item.note_id = note._id and item.other_id = other._id"