Multitask Database and ICS

I have code that creates a database with two tables.

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 try to execute a query in both tables, I get "There is no such Travaux table"

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 great on my HC tablet, but not on my ICS. Any idea?

+3
source share
1 answer

In the SQLiteDatabase.execSQL () documentation:

Execute a single SQL statement ...

So, although your code works on some devices, try breaking your build instructions into two commands:

@Override
public void onCreate(SQLiteDatabase database) {
    database.execSQL(tablecommandes);
    database.execSQL(tabletravaux);
}
+3
source

All Articles