开发者

Android SQL query problem

开发者 https://www.devze.com 2023-02-12 15:29 出处:网络
I\'m hitting a wall in an android SQL query, this is what I have so far: 开发者_StackOverflowmDb.query(false, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_ROWONE, KEY_ROWTWO, KEY_ROWTHREE, KEY_ROWFOU

I'm hitting a wall in an android SQL query, this is what I have so far:

        开发者_StackOverflowmDb.query(false, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_ROWONE, KEY_ROWTWO, KEY_ROWTHREE, KEY_ROWFOUR, KEY_ROWFIVE}, KEY_ROWONE +" LIKE '?%'", new String[] { letter }, null, null, null, null);

Basically, I want the query to return all the rows in the table where KEY_ROWONE starts with the variable letter (a string containing one letter).

I get a force close when I'm running the code, and I'm really puzzled.

I promise to tick the best answer!


It's alright guys, panic over, I found the solution:

mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_ROWONE, KEY_ROWTWO, KEY_ROWTHREE, KEY_ROWFOUR, KEY_ROWFIVE}, KEY_ROWONE+" LIKE ? || '%'", new String[] { l }, null, null, null, null);


Just in case someone will be interested, here's full database tutorial for android: http://knightswhocode.com/wordpress/?p=14

0

精彩评论

暂无评论...
验证码 换一张
取 消