I have a code that creates a database with 2 tables in it.
private static final String tablecommandes="CREATE TABLE Commandes (no INTEGER NOT NULL PRIMARY KEY,equipe TEXT NULL,nom TEXT NULL,adresse TEXT NULL,ville TEXT NULL,tel TEXT NULL,frequence INTEGER NULL,datelastserv TIMESTAMP NULL,priorite INTEGER NULL);";
private static final String tabletravaux="CREATE TABLE Travaux (notrav INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, travid TEXT NULL, notravlogiciel INTEGER NULL, nocom INTEGER NULL, debut TIMESTAMP NULL,fin TIMESTAMP NULL,temps INTEGER NULL);";
private static final String DATABASE_CREATE = tablecommandes+" "+tabletravaux;
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}
When I’m trying to do a query on both tables I get “No such table Travaux”
public Cursor fc() throws SQLException {
Cursor mCursor = database.query(true, "Commandes , Travaux", new String[] {
Fieldno,FieldNom,FieldAdresse,Fieldville,Fieldtel,Fieldfreq,Fieldlastserv,Fieldequipe},
"Commande.NoCommande=Travaux.NoCommande",null, null, null, null,null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
This works fine on my HC tablet but not on my ICS one.
Any idea?
From the SQLiteDatabase.execSQL() documentation:
So even though your code works on some devices, try breaking your build statements into two commands: