问题描述
我试图找出做一个简单的表连接在一个Android应用程序中使用SQLite数据库我的两个表的最佳途径。就是用CursorJoiner最简单的方法或者是还有什么更简单的方法?
I am trying to find out the best way to do a simple table join on my two tables using a sqlite database in an android application. Is the simplest way to use CursorJoiner or is there any easier way?
推荐答案
在<一实施href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/database/sqlite/SQLiteDatabase.java;h=d4f9b2008b83f0131a57800eddf636391c88d492;hb=HEAD">SQLiteDatabase和<一href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/database/sqlite/SQLiteQueryBuilder.java;h=610bf7013e099f303e9ab67d6b4ef899a2bc03c2;hb=HEAD">SQLiteQueryBuilder你会看到,它有可能通过你想加入到表中的参数表href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query%28java.lang.String,%20java.lang.String%5b%5d,%20java.lang.String,%20java.lang.String%5b%5d,%20java.lang.String,%20java.lang.String,%20java.lang.String%29"><$c$c>query$c$c>即使文档意味着将只需要一台单一的名字。该文档SQLiteQueryBuilder为更清晰,甚至建议像
FOO,酒吧
或富LEFT OUTER JOIN栏上(foo.id = bar.foo_id)
。
In the implementation of SQLiteDatabase and SQLiteQueryBuilder you will see that it is possible to pass the tables you want to join to the table
argument of query
even though the documentation implies it will only take a single name of a table. The documentation for SQLiteQueryBuilder is more clear and even suggests things like foo, bar
or foo LEFT OUTER JOIN bar ON (foo.id = bar.foo_id)
.
这篇关于投身于Android的使用SQLite表的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!