I’m trying to insert text into my SQLite database, but for some reason it doesn’t work. It never executes..
Code below (this is my function that I’m calling):
public void setInfo(final String tableName, final int id, final String title, final String time, final String content) {
final String sql = "INSERT INTO " + tableName + "("+DB_COLUMN_ID+", "+DB_COLUMN_TITLE+", "+DB_COLUMN_TIME+","+DB_COLUMN_CONTENT+")" +
" VALUES ('"+id+"', '"+title+"', '"+time+"','"+content+"";
final SQLiteStatement stmt = mDatabase.compileStatement(sql);
stmt.execute();
}
Thanks in advance!
Looks like you are missing the final single quote and the closing parenthesis on the sql statement. Also the id is type int so it doesn’t need any quotes at all. I’m guessing it should read: