0

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 = Австралийский доллар)

1 Answer 1

1

Try surrounding your name with quote

String w=CurrencyProvider.KEY_NAME+" = '"+_currency.getName() + "'";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.