你好,我是 android 中 sqlite 的初学者,我创建了一个 2 个表的数据库,我正在尝试在第二个表中创建一个外键,这是第一个表的 id,这是代码,如果你告诉我,我将不胜感激如果代码中还有其他错误,尤其是查询中的错误,请提前谢谢
package com.example.hp.memorybackup;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.sql.SQLException;
/**
* Created by hp on 13/04/2015.
*/
public class SanaHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "memorydatabase";
private static final String TABLE_NOTE_NAME = "NOTETABLE";
private static final int DATABASE_VERSION = 1;
private static final String UID_NOTE = "_idnote";
private static final String TITRE = "Titre";
private static final String OBJET = "Objet";
private static final String PRAM_N = "Prametres_note";
private static final String CREATE_NOTE = "CREATE TABLE" + TABLE_NOTE_NAME + "(" + UID_NOTE + " INTEGER PRIMARY KEY AUTOINCREMENT," + TITRE + " VARCHAR (255)" + OBJET + "VARCHAR (255)" + PRAM_N + "VARCHAR (255) ;";
private static final String TABLE_USER_NAME = "USERTABLE";
private static final String UID_USER = "_iduser";
private static final String NOM = "Nom";
private static final String PRENOM = "Prenom";
private static final String DATE_NAISS="Date_Naiss";
private static final String E_MAIL = "E-mail";
private static final String LOGIN = "Login";
private static final String MOT_PASSE = "Mot-passe";
private static final String CREATE_USER = "CREATE TABLE" + TABLE_USER_NAME + "(" + UID_USER + " INTEGER PRIMARY KEY AUTOINCREMENT," + NOM + " VARCHAR (255)" + PRENOM + "VARCHAR (255)" + DATE_NAISS + "DATE "
+ LOGIN + " VARCHAR (255) "+MOT_PASSE+" VARCHAR (255);";
private Context context;
public SanaHelper(Context context) {
super(context, "DATABASE_NAME", null, 1);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_NOTE);
db.execSQL(CREATE_USER);
} catch (android.database.SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
}