i have a problem with sqlite. in my app i get voice recognition to edit text and then storing this string in sqlite. its work very good, the problem is when i try to say word like "don't" and try to save it to sqlite, the app crash becouse its exeption for sqlite. any solution?
this is the on activity result for voice recognition:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQ_CODE_TAG_INPUT: {
if (resultCode == RESULT_OK && null != data) {
ArrayList<String> result = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (!result.get(0).equals("delete all")) {
et1.setText(et1.getText().toString() + " " + result.get(0));
} else {
et1.setText("");
}
}
break;
}
and this is the save method for sqlite:
if (!et1.getText().toString().equals("")
&& !et2.getText().toString().equals("")) {
tag = et1.getText().toString();
des = et2.getText().toString();
Notes.getInstance().getmNotes()
.add(new MyNote(tag, des, date, 1, id));
MyOH oh = new MyOH(getApplicationContext());
mDb = oh.getWritableDatabase();
if (MainActivity.state == 1) {
mDb.execSQL("UPDATE note SET tag='" + tag + "',des='" + des
+ "',time='" + date + "',noteid=" + id
+ " WHERE noteid = " + id);
} else {
mDb.execSQL("INSERT INTO note VALUES ('" + tag + "','" + des
+ "','" + date + "'," + id + ")");
}
this is the exeption:
Caused by: android.database.sqlite.SQLiteException: near "t": syntax error (code 1): , while compiling: INSERT INTO note VALUES ('No Tag','don't','28/11/2014',-133663026
thanks for helping!!