When I changed the device language, app crashes

橙三吉。 提交于 2020-04-17 22:57:50

问题


I used SQLite and in my project it works well if the device language is in English. However if I change the device language I get an error which is;

    java.lang.IllegalArgumentException: the bind value at index 1 is null

....

com.radioapps.radiostations2020.models.DatabaseHelper.getRadioNamesByCountryName(DatabaseHelper.java:127)

line 127 is;

   Cursor c = myDataBase.rawQuery(query, new String[]{string});

and the whole method is;

public List<String> getRadioNamesByCountryName(String string) {

    List<String> list = new ArrayList<>();
    myDataBase = this.getWritableDatabase();
    String query = "SELECT name FROM second WHERE country=?";
    Cursor c = myDataBase.rawQuery(query, new String[]{string});
    while (c.moveToNext()) {
        list.add(c.getString(c.getColumnIndex("name")));
    }
    c.close();
    return list;
}

来源:https://stackoverflow.com/questions/60964966/when-i-changed-the-device-language-app-crashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!