I'm getting this error in my app when I try to write to database E/SQLiteLog: (1) near "-": syntax error please can you help me... Here is my code for SQLite databse. I am attaching the complete code for database class here
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/**
* Created by TOSHIBA on 01/05/2016.
*/
// CREATION DATABASE
public class DatabaseHelper extends SQLiteOpenHelper {
private SQLiteDatabase db;
private static final String DATABASE_NAME = "QuickTowing.db";
private static final String QUERY =
"CREATE TABLE "+ TablesDB.NewClientInfo.TABLE_NAME+"("+ TablesDB.NewClientInfo.COL_1+" INTEGER PRIMARY KEY AUTOINCREMENT,"
+ TablesDB.NewClientInfo.COL_2+" TEXT,"+ TablesDB.NewClientInfo.COL_3+" TEXT,"+ TablesDB.NewClientInfo.COL_4+" TEXT,"
+ TablesDB.NewClientInfo.COL_5+" INTEGER,"+ TablesDB.NewClientInfo.COL_6+" TEXT,"+ TablesDB.NewClientInfo.COL_7+" TEXT,"
+ TablesDB.NewClientInfo.COL_8+" TEXT);";
//CREATE DATABASE
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
Log.e("Database operations","database created / opened... ");
}
//CREATE TABLECLIENT
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(QUERY);
Log.e("Database operations","Table created...");
}
//ADD CLIENT
public void addClientInformations (Integer CIN,String name, String surname,String email,Integer phone,String password, String vehType,String vehModel, SQLiteDatabase db){
ContentValues contentValues = new ContentValues();
contentValues.put(TablesDB.NewClientInfo.COL_1,CIN );
contentValues.put(TablesDB.NewClientInfo.COL_2,name );
contentValues.put(TablesDB.NewClientInfo.COL_3,surname );
contentValues.put(TablesDB.NewClientInfo.COL_4,email );
contentValues.put(TablesDB.NewClientInfo.COL_5,phone );
contentValues.put(TablesDB.NewClientInfo.COL_6,password );
contentValues.put(TablesDB.NewClientInfo.COL_7,vehType );
contentValues.put(TablesDB.NewClientInfo.COL_8,vehModel );
db.insert(TablesDB.NewClientInfo.TABLE_NAME,null,contentValues);
Log.e("Database operations","One row inserted...");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
Aucun commentaire:
Enregistrer un commentaire