2009年2月5日 星期四

使用SQLite時的引號注意事項

如果你使用SQLiteQueryBuilder和ContentValues來作insert/update,那你不需要對字串作任何處理。
可是在query的時候,WHERE CLAUSE裡面你必須加上單引號,或是自建一個WhereClauseBuilder:

public static class WhereClauseBuilder {
public static String whereKeyEquals(String key, String value) {
return key + "='" + value + "'";
}
}
####

沒有留言:

CODE { display: block; /* fixes a strange ie margin bug */ font-family: Courier New; font-size: 8pt; overflow:auto; background: #f0f0f0 url(http://klcintw.images.googlepages.com/Code_BG.gif) left top repeat-y; border: 1px solid #ccc; padding: 10px 10px 10px 21px; max-height:200px; height:200px; // for IE6 line-height: 1.2em; } #quote { display: block; /* fixes a strange ie margin bug */ font-family: Verdana; font-size: 10pt; overflow:auto; background: #f7f7f7 url(http://lh5.ggpht.com/_z-VThISftkI/SXUlpyfw9ZI/AAAAAAAABYY/e3GUx9_Z4TE/s288/quote-l.gif) left top no-repeat; border: 4px dotted #ccc; padding: 15px 15px 15px 31px; /*up right bottom left*/ max-height:300px; line-height: 1.2em; }