I have created this table
private static class PuntataMetaData {
static final String TABLE_NAME = "puntata";
static final String ID = "_id";
static final String PALINSESTO = "palinsesto";
static final String NUMEROPALINSESTO = "numeroPalinsesto";
static final String ESITO = "esito";
static final String PARTITA = "partita";
static final String QUOTAZIONE = "quotazione";
}
private static final String PUNTATA_TABLE_CREATE =
"CREATE TABLE " + PuntataMetaData.TABLE_NAME + " (" +
PuntataMetaData.ID + " integer primary key autoincrement, " +
PuntataMetaData.PALINSESTO + " double not null, " +
PuntataMetaData.NUMEROPALINSESTO + " integer not null, " +
PuntataMetaData.ESITO + " text not null, " +
PuntataMetaData.PARTITA + "text not null," +
PuntataMetaData.QUOTAZIONE + " text not null);";
Now when I search to execute this code
public void inserisciInSchedina(Partite p, String esito, String quot){
db = getWritableDatabase();
ContentValues cv = createPuntataContentValues(p.getPalinsesto(), p.getNumeroEvento(), esito, quot, p.getPartita());
db.insert(PuntataMetaData.TABLE_NAME, null, cv);
db = getReadableDatabase();
}
private ContentValues createPuntataContentValues(long pal, int numPal, String temp, String temp1, String par) {
ContentValues cv = new ContentValues();
cv.put(PuntataMetaData.PALINSESTO, pal);
cv.put(PuntataMetaData.NUMEROPALINSESTO, numPal);
cv.put(PuntataMetaData.ESITO, temp);
cv.put(PuntataMetaData.PARTITA, "Inter-Roma");
cv.put(PuntataMetaData.QUOTAZIONE, temp1);
return cv;
}
The Android's debug said to me the following error:
android.database.sqlite.SQLiteException: table puntata has no column named partita: , while compiling: INSERT INTO puntata(numeroPalinsesto,esito,quotazione,partita,palinsesto) VALUES (?,?,?,?,?)
I don't understand where is the error because the field "Partita" exists into the DB Thanks
SQLiteon Android your create statement is probably not called again and so the table doesn't have the column.SQLitework together. Here's a good tutorial: vogella.com/articles/AndroidSQLite/article.html Anyways - try to remove your app from the device and install it again and see if it helps. If this helps, I'll throw a comprehensive answer to your question and explain exactly why this happens. :-)