My sqlite query got error due to value of CharSequence s. In this value i have single quote(people's) which is not running properly. the query is running correct with double time single quote(people''s).
and code error is like below
07-27 14:48:32.042: E/SQLiteLog(28325): (1) near "s": syntax error
07-27 14:48:32.052: E/AndroidRuntime(28325): FATAL EXCEPTION: main
07-27 14:48:32.052: E/AndroidRuntime(28325): Process:
com.compare.WorldAtlasPro, PID: 28325 07-27 14:48:32.052:
E/AndroidRuntime(28325): android.database.sqlite.SQLiteException: near
"s": syntax error (code 1): , while compiling: SELECT Name FROM
country_info WHERE Name LIKE '%People's Republic of China%' AND Name
NOT LIKE ''AND Name NOT LIKE '' AND Name NOT LIKE ''AND Name NOT LIKE
'' order by Name ASC
Here below of my code.
country2.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
ArrayList<String> mArrayList=new ArrayList<String>();
Cursor c=db.rawQuery("SELECT Name FROM country_info WHERE Name LIKE '%"+s+"%' AND" +" Name NOT LIKE'"+country1.getText().toString()+"'AND Name NOT LIKE'"+country3.getText().toString()+"' " +" AND Name NOT LIKE'"+country4.getText().toString()+"'AND Name NOT LIKE'"+country5.getText().toString()+"' " + "order by Name ASC", null);
while(c.moveToNext()){
mArrayList.add(c.getString(0));
}
country2.setAdapter(new CustomAdapter(mCtx,mArrayList));
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void afterTextChanged(Editable s) {
}
});