Création de table SQLLITE
Bonjour,
J'essaie de créer une base de données sur SQLLITE, mais il ne me crée pas la deuxième table !!!
******
EDIT
Oublier la valeur des variables
Code:
1 2 3 4 5 6 7 8
|
private static final String SMS_TABLE = "sms";
private static final String SMS_ID = "ID_SMS";
private static final String MOT_CLE = "MOT_CLE";
private static final String TABLE_OPTIONS = "sms_options";
private static final String OPTION_ID = "OPTION_ID";
private static final String NOM_OPTION = "NOM_OPTION";
private static final String VALUE_OPTION = "VALUE_OPTION"; |
*******
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
private static final String CREATE_BDD = "CREATE TABLE " + SMS_TABLE + " ("
+ SMS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + MOT_CLE + " TEXT NOT NULL);";
private static final String CREATE_BDD2 = "CREATE TABLE " + TABLE_OPTIONS + " ("
+ OPTION_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + NOM_OPTION + " TEXT NOT NULL,"
+ VALUE_OPTION + " TEXT NOT NULL);";
public MaBaseSQLite(Context context, String name, CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
//on créé la table à partir de la requête écrite dans la variable CREATE_BDD
db.execSQL(CREATE_BDD);
db.execSQL(CREATE_BDD2);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
06-06 09:57:21.646: E/AndroidRuntime(321): Uncaught handler: thread main exiting due to uncaught exception
06-06 09:57:21.665: E/AndroidRuntime(321): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.projet/com.test.projet.OptionsActivity}: android.database.sqlite.SQLiteException: no such table: sms_options: , while compiling: SELECT VALUE_OPTION FROM sms_options WHERE NOM_OPTION = flash
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.os.Looper.loop(Looper.java:123)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread.main(ActivityThread.java:4363)
06-06 09:57:21.665: E/AndroidRuntime(321): at java.lang.reflect.Method.invokeNative(Native Method)
06-06 09:57:21.665: E/AndroidRuntime(321): at java.lang.reflect.Method.invoke(Method.java:521)
06-06 09:57:21.665: E/AndroidRuntime(321): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-06 09:57:21.665: E/AndroidRuntime(321): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-06 09:57:21.665: E/AndroidRuntime(321): at dalvik.system.NativeStart.main(Native Method)
06-06 09:57:21.665: E/AndroidRuntime(321): Caused by: android.database.sqlite.SQLiteException: no such table: sms_options: , while compiling: SELECT VALUE_OPTION FROM sms_options WHERE NOM_OPTION = flash
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1221)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1108)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1066)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1143)
06-06 09:57:21.665: E/AndroidRuntime(321): at com.test.projet.SMSBDD.nb_enregistrement_flash(SMSBDD.java:99)
06-06 09:57:21.665: E/AndroidRuntime(321): at com.test.projet.OptionsActivity.onCreate(OptionsActivity.java:38)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-06 09:57:21.665: E/AndroidRuntime(321): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) |
Pourtant la table sms est bien crée sans problème, je ne vois pas de problème de syntaxe dans ma requete !
Quelqu'un a une idée ?