Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a databse that contains: id , playlistname , playlistnum and I want to get alll the rows where playlistname = "CoolPlaylist" and I want to parse them 1 by 1, so I thought of doing this:

String name = "CoolPlaylist"; 
String[] columns = String[] {id , playlistname , playlistnum};
Cursor c = myDatabase.query(TABLE_NAME, columns, key_playlistname +"="+name,
                            null, null, null, null);

but when I do this, the code crashes. Does somebody know what the problem probably is?

share|improve this question
3  
I guessing it's something to do with those nulls. You need to debug the program. Read the error message, they're typically very helpful. Use the debugger, step through the code, ensure your values are set the way you expect them to be set. –  Byte56 Jul 15 '12 at 15:13
add comment

closed as off topic by Joe Wreschnig, Tetrad Jul 16 '12 at 4:08

Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

This portion of your code

key_playlistname +"="+name

probably needs the name part in quotes

i.e.

key_playlistname + "= '" + name + "'"

Otherwise CoolPlayList probably be treated as an SQL command and would come back with an error such as invalid SQL statement.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.