samedi 7 mars 2015

Java StringBuilder DISSAPEARING quotation marks

I need to make a string for SQLite select functionin the format of :



...AND value_data IN ('FOX','BARTLETT')



where 'FOX' and 'BARTLETT' are placeholders for 1+ variable names, all surrounded by single quote and comma separated. Here is my code:



StringBuilder build = new StringBuilder();
build.append(") AND value_data IN (");
build.append("'" + values[0] + "'"); //guaranteed first value
for(int l = 1; l < (values.length); l++){
build.append(",'" + values[l] + "'"); //any number of values afte
}
build.append(")");


But when i print out the build.toString(), I get this:



...AND value_data IN ('FOX,BARTLETT')



The interior single quotes that should be before and after the comma vanish. I've looked all over the internet (this site and others) for the answer but can't find it. Why are these quotes dissapearing and how can I make the the String build like shown at the top?


Aucun commentaire:

Enregistrer un commentaire