Reputation:
I have application, which downloads data from internet and is supposed to write it to DB using content provider.
private void addCurrency(Currency _currency){
ContentResolver cr=getContentResolver();
ContentValues values = new ContentValues();
values.put(CurrencyProvider.KEY_DATE, _currency.getDate().getTime());
values.put(CurrencyProvider.KEY_NAME, _currency.getName());
values.put(CurrencyProvider.KEY_NOMINAL, _currency.getNominal());
values.put(CurrencyProvider.KEY_VALUE, _currency.getValue());
String w=CurrencyProvider.KEY_NAME+" = "+_currency.getName();
if (cr.query(CurrencyProvider.CONTENT_URI, null, w,null , null).getCount()==0){
cr.insert(CurrencyProvider.CONTENT_URI, values);
}else
cr.update(CurrencyProvider.CONTENT_URI, values, w, null);
}
So, I'm trying either to update record if it exists, or to add new. But I'm getting SQLite exception: near "доллар": syntax error: , while compiling: SELECT * FROM currency WHERE (name = Австралийский доллар)
Upvotes: 0
Views: 560
Reputation: 49410
Try surrounding your name with quote
String w=CurrencyProvider.KEY_NAME+" = '"+_currency.getName() + "'";
Upvotes: 1