我正在尝试在数据库中创建多个表,但第一个表仅创建成功,另外两个给我错误我想知道如何确保创建表
04-18 17:20:45.343: E/AndroidRuntime(956): android.database.sqlite.SQLiteException: no such table: squares: , while compiling: SELECT _squareid, squarename, squarelatitude, squarelongitude FROM squares
这是我的代码
public class Dbinfo {
public static final String KEY_RAWID = "_id";
public static final String KEY_RAWNAME = "name";
public static final String KEY_PASSWORD = "password";
public static final String KEY_EMAIL = "email";
public static final String KEY_SQUAREID = "_squareid";
public static final String KEY_SQUARENAME = "squarename";
public static final String KEY_SQUARELATITUDE = "squarelatitude";
public static final String KEY_SQUARELONGITUDE = "squarelongitude";
private static final String KEY_STREETID = "streetid";
private static final String KEY_STREETNAME = "streetname";
private static final String KEY_STREETLATITUDE="streetlatitude";
private static final String KEY_STREETLONGTIUDE="streetlongtiude";
private static final String KEY_STREETCAPACITY = "streetcapacity";
private static final String KEY_STREETFOREIGN = "streetforegin";
private static final String DATABASE_NAME = "users_DB";
private static final String DATABASE_TABLE = "users";
private static final String DATABASE_TABLESQUARES = "squares";
private static final String DATABASE_TABLE_STREETS = "streets";
private static final int DATABASE_VERSION = 1;
private dbusers ourhelper;
private final Context ourcontext;
private static SQLiteDatabase ourDatabase;
private static class dbusers extends SQLiteOpenHelper {
public dbusers(Context context) {
super(context, DATABASE_TABLE, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE " + DATABASE_TABLE + "(" + KEY_RAWID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_RAWNAME
+ " TEXT NOT NULL, " + KEY_PASSWORD + " TEXT NOT NULL, "
+ KEY_EMAIL + " TEXT NOT NULL);");
db.execSQL("CREATE TABLE " + DATABASE_TABLESQUARES + "("
+ KEY_SQUAREID + "INTEGER PRIMARY KEY AUTOINCREMENT, "
+ KEY_SQUARENAME + "TEXT NOT NULL, " + KEY_SQUARELATITUDE
+ "TEXT NOT NULL, " + KEY_SQUARELONGITUDE
+ "TEXT NOT NULL);");
final String STREET = "CREATE TABLE " + DATABASE_TABLE_STREETS
+ " (" + KEY_STREETID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_STREETNAME+
" TEXT NOT NULL"+KEY_STREETLATITUDE+"TEXT NOT NULL"+KEY_SQUARELONGITUDE
+ " TEXT NOT NULL, " + KEY_STREETCAPACITY
+ " text not null, FOREIGN KEY (" + KEY_STREETFOREIGN
+ ") REFERENCES " + DATABASE_TABLESQUARES + " ("
+ KEY_SQUAREID + "));";
db.execSQL(STREET);
有什么帮助吗??