【发布时间】:2012-04-09 07:25:03
【问题描述】:
我正在为商店开发一个安卓应用程序,它提供了许多功能。其中之一是允许客户使用某些标准(价格、尺寸、类型...如图所示)搜索产品的功能。
我想我应该使用SqliteDatabase,但我不知道如何制作这个多条件搜索界面,以便用户可以查询数据库。
【问题讨论】:
标签: android database sqlite search
我正在为商店开发一个安卓应用程序,它提供了许多功能。其中之一是允许客户使用某些标准(价格、尺寸、类型...如图所示)搜索产品的功能。
我想我应该使用SqliteDatabase,但我不知道如何制作这个多条件搜索界面,以便用户可以查询数据库。
【问题讨论】:
标签: android database sqlite search
这很简单。设置好数据库后,您可以使用 SQL 查询和 JOIN 类型与 WHERE critaria 并最终获得正确的数据,使用 Cursor 类遍历结果。
见: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html
http://www.w3schools.com/sql/sql_where.asp
【讨论】:
在处理它之前,您应该正确设计您的数据库。 认为, 表格列表 -
1) product_type(_id<should be primary key to link another table>,
type_id<integer>, type_name<text>
2) product_price(_id<should be primary key to link another table>,
type_id<integer>, price<double>
3) product_type_size(_id<should be primary key to link another table>, type_id<integer>, size<text>
并根据您的要求创建视图 - product_search(正确加入你的表) 并根据需要运行您的查询并与视图的值相匹配。
继续--
【讨论】: