mercredi 31 décembre 2014

Android SQLite Database: Syntax error when adding to database

Hi I'm getting this error when adding data to my database but i can't figure out why. I think the problem is in the addData()-Method, but none of my atempts to fix it have worked so far.


"E/SQLiteLog﹕ (1) near "Aktivität": syntax error"


as well as:


"android.database.sqlite.SQLiteException: near "Aktivität": syntax error (code 1): , while compiling: INSERT INTO MedDatenTabelle(Schmerz,Broteinheiten,Messzeit,Wasser,Diastole,Müdigkeit,Puls,Symptom,letzte Aktivität,Gewicht,Kalorien,Bemerkungen,Systole,Temperatur,Blutzucker) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"


public class DatabaseHandler extends SQLiteOpenHelper {



private static final int DATABASE_VERSION = 1;

private static final String DATABASE_NAME= "MedDatenManager";

private static final String TABLE_MEDDATEN = "MedDatenTabelle";


private static final String KEY_ID = "id";
private static final String KEY_SYST = "Systole";
private static final String KEY_DIAST = "Diastole";
private static final String KEY_PULS = "Puls";
private static final String KEY_BLUTZ = "Blutzucker";
private static final String KEY_TEMP = "Temperatur";
private static final String KEY_GEW = "Gewicht";
private static final String KEY_KAL = "Kalorien";
private static final String KEY_BE ="Broteinheiten";
private static final String KEY_WASSER = "Wasser";
private static final String KEY_TIME = "Messzeit";
private static final String KEY_SCHMERZ = "Schmerz";
private static final String KEY_MUD = "Müdigkeit";
private static final String KEY_AKTI = "letzte Aktivität";
private static final String KEY_SYMP = "Symptom";
private static final String KEY_BEM = "Bemerkungen";

public DatabaseHandler(Context context){
super(context,DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase database) {
String CREATE_TABLE_MEDDATEN = "CREATE TABLE " + TABLE_MEDDATEN + " ("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_SYST + " TEXT,"
+ KEY_DIAST + " TEXT," + KEY_PULS + " TEXT," + KEY_BLUTZ + " TEXT,"
+ KEY_TEMP + " TEXT," + KEY_GEW + " TEXT," + KEY_KAL + " TEXT,"
+ KEY_BE + " TEXT," + KEY_WASSER + " TEXT," + KEY_TIME + " TEXT,"
+ KEY_SCHMERZ + " TEXT," + KEY_MUD + " TEXT," + KEY_AKTI + " TEXT,"
+ KEY_SYMP + " TEXT," + KEY_BEM + " TEXT" + " )";
database.execSQL(CREATE_TABLE_MEDDATEN);
}

@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
database.execSQL("DROP TABLE IF EXISTS " + TABLE_MEDDATEN);

onCreate(database);
}

public void addData (MEDDATEN meddaten){
SQLiteDatabase database = this.getWritableDatabase();

ContentValues values = new ContentValues();

values.put(KEY_SCHMERZ,meddaten.getSchmerz());
values.put(KEY_BE,meddaten.getBroteinheiten());
values.put(KEY_TIME,meddaten.getMesszeit());
values.put(KEY_WASSER,meddaten.getWasser());
values.put(KEY_MUD,meddaten.getMüdigkeit());
values.put(KEY_DIAST,meddaten.getDiastole());
values.put(KEY_PULS,meddaten.getPuls());
values.put(KEY_SYMP,meddaten.getSymptome());
values.put(KEY_AKTI,meddaten.getLetzteAkt());
values.put(KEY_GEW,meddaten.getGewicht());
values.put(KEY_KAL,meddaten.getKalorien());
values.put(KEY_BEM,meddaten.getBemerkungen());
values.put(KEY_TEMP,meddaten.getTemperatur());
values.put(KEY_SYST,meddaten.getSystole());
values.put(KEY_BLUTZ,meddaten.getBlutzucker());

database.insert(TABLE_MEDDATEN, null, values);
database.close();

}




}


}


Aucun commentaire:

Enregistrer un commentaire