I am trying to insert the values from an array in a SQLite database. The problem is that the function inserts only null values eventhough the array does not contain such values.
The function for insert :
public void addArrayEntry(String [] response){
try {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
//System.out.println(response.length);
for (int i=1; i<response.length; i++){
values.put(temperature,response[i]);
db.insert(tableStatistics,null,values);
}
db.close();
}
catch (Exception e){
Log.e("Error in insert", e.toString());
}
}
String createTable = "CREATE TABLE statistics ( " +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"temperature REAL, "+
"light INTEGER, "+
"humidity INTEGER)";
Array values :
05-08 14:24:21.405 10720-10720/org.security.andreiism.iotsecurity I/System.out﹕ 23.798828125 05-08 14:24:21.405 10720-10720/org.security.andreiism.iotsecurity I/System.out﹕ 744 05-08 14:24:21.405 10720-10720/org.security.andreiism.iotsecurity I/System.out﹕ 424
Aucun commentaire:
Enregistrer un commentaire