I wrote a code snippet like this:
//query SELECT name FROM sqlite_master WHERE type = "table" AND
name="table_name"
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables("sqlite_master");
qb.appendWhere("type='table'");
qb.appendWhere("name='" + name + "'");
final String[] projectionIn = { "name" };
String sql = qb.buildQuery(projectionIn, null, null, null,
null, null, null);
then i got the sql statement:
SELECT name FROM sqlite_master WHERE (type='table'name='qq_rms_ver')
there is no word between two conditions.
Q1: Method appendWhere can only append ONE query condition? why it
named "append"?
then i tried to edit the code.
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables("sqlite_master");
qb.appendWhere("type='table' AND name='" + name + "'");
final String[] projectionIn = { "name" };
String sql = qb.buildQuery(projectionIn, null, null, null,
null, null, null);
//////// here can get right sql statement SELECT name FROM
sqlite_master WHERE (type='table' AND name='qq_rms_ver')
Cursor cursor = null;
try {
cursor = qb.query(database, projectionIn, null, null,
null, null, null);
}
catch (Exception e1) {
e1.printStackTrace();
}
and an Exception caught.
android.database.sqlite.SQLiteException: near "name": syntax error: ,
while compiling: SELECT name FROM sqlite_master WHERE
(type='table'name='qq_rms_ver'))
Q2: Why a bracket ')' is append to the end of the sql statement when
execute the query?
Are they bugs?or i didn't understande the usage of the methods?
help me,pls!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---