my android app is crashing with this exception
12-02 12:40:50.145: E/AndroidRuntime(531): Caused by:android.database.sqlite.SQLiteException: near "(": syntax error: , while compiling: insert into target(username, (password, (lastLogin, (numberOfLogins, (status, (endpoint) values (?,?,?,?,?,?)
My insert statement in the code looks like this
private static final String INSERT = "insert into " + AttachmentTable.TABLE_NAME
+ " (" + AttachmentColumns.STATUS + ", "
+ AttachmentColumns.RETRIES + ", "
+ AttachmentColumns.ATT_URI + ", "
+ AttachmentColumns.ATT_URI_SOURCE + ", "
+ AttachmentColumns.COMMENT+ ", "
+ AttachmentColumns.ADDED + ", "
+ AttachmentColumns.LAST_RETRY + ", "
+ AttachmentColumns.FINISHED + ") " +
"values (?,?,?,?,?,?,?,?)";
In the code I tried to save one of the created attachments. But it does not work. In the Android File Explorer I could see that the database has been created. Here the save part from my code
DataManager data = new DataManagerImpl(this);
Attachment att = new Attachment();
att.setAdded("now");
att.setAttUri("test");
att.setAttUriSource("test");
att.setComment("test");
att.setLastRetry("test");
att.setRetries(3);
att.setStatus(0);
data.setAttachment(att);
And here the setAttachment code
@Override
public boolean setAttachment(Attachment t) {
boolean retVal = false;
try{
db.beginTransaction();
long result = attDao.save(t);
if (result != -1)
retVal = true;
}catch (SQLException e) {
Log.e(TAG, "Exception during saving target " + e.getMessage() + " rolling back transaction");
} finally{
db.endTransaction();
}
return retVal;
}
to insert just do this
and