Reputation: 56
Is there a way to save strings that contain an apostrophe into an sqlite database?
(I have an app that saves the names of all installed apps on your device and ran into an error while saving "Dood's Music Streamer")
Upvotes: 1
Views: 1464
Reputation: 201429
You could use a compiled statement and bind the String
parameter.
SQLiteDatabase db = dbHelper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("INSERT INTO FOO (NAME) VALUES (?)");
stmt.bindString(1, "Dood's Music Streamer");
stmt.execute();
Upvotes: 1
Reputation: 101
I'm not familiar with sqlite, but it might need an escape character similar to Java and C++, for example Dood\'s Music Streamer
Upvotes: 0