How can i get quoted strings in a ContentValues object to be used in a sqlite insert? SQLite seems to be choking on the : of my value
//inside a for loop of a NodeList
ContentValues map = new ContentValues();
Element elm;
elm = (Element) nodes.item(i);
String elmname = elm.getTagName();
map.put("foto", getValue(elm, "foto"));
map.put("fotonormal", getValue(elm, "foto-normal"));
map.put("link", getValue(elm, "link"));
myDatabase.beginTransaction();
try {
myDatabase.insertOrThrow(TABLE_ENDING, null, map);
Log.i(TAG, "Added");
myDatabase.setTransactionSuccessful();
} catch (Exception err) {
Log.i(TAG, "Transaction failed. Exception: " + err.getMessage());
} finally {
myDatabase.endTransaction();
}
which gives me this error
Transaction failed. Exception: unrecognized token: ":": INSERT INTO tbl_ending (fotonormal, foto, link) VALUES (https://example.com/fotonormal.jpg, https://example.com/foto.jpg, https://example.com/);
i believe the SQL statement should be
INSERT INTO tbl_ending (fotonormal, foto, link) VALUES ("https://example.com/fotonormal.jpg", "https://example.com/foto.jpg", "https://example.com/");
How can I get this output instead?
Phillip’s answer put me on the right path, I cast the return value of the function getValue as a string
and now i can successfully insert.