i'm trying to insert some data into a SQLite3 Database on an Android system.
This method should takes three strings and insert them into a database:
public void createEntry(String description, String reps, String weight)
{
ContentValues cv = new ContentValues();
cv.put(KEY_DESCRIPTION, description);
cv.put(KEY_REPS, reps);
cv.put(KEY_WEIGHT, weight);
sqlDB.insert(DATABASE_TABLE, null, cv);
}
The columns(KEY_DESCRIPTION,..) are all defined as TEXT NOT NULL and I also added an auto incrementing column.
In my main activity I'm using this code to get input from EditText Widgets
String description = sqlDescription.getText().toString();
then I'm creating an instance of my DB class:
DB entry = new DB(MainActivity.this);
entry.open();
entry.createEntry(description, reps, weight);
entry.close();
open() uses the SQLiteOpenHelper and sets up database:
public DB open()
{
sqlHelper = new dbHelper(sqlContext);
sqlDB = sqlHelper.getWritableDatabase();
return this;
}
But when I call this method:
entry.createEntry(description, reps, weight);
I get following error:
(1) near "Table": syntax error
E/SQLiteDatabase(19344): Error inserting Description=test Weight=tesz Reps=test
E/SQLiteDatabase(19344): android.database.sqlite.SQLiteException: near "Table": syntax error
(code 1): , while compiling: INSERT INTO Table(Description,Weight,Reps) VALUES (?,?,?)
DATABASE_TABLEString