我正在尝试创建一个数据库并在我的Android手机上运行我的应用程序,因为我的模拟器不起作用。我在之前的数据库中做了一些改进,这些更改非常完美。我刚刚在我的代码中添加了另一个创建表查询。现在它不是在创建数据库。我也更改了db的名称。但没有结果!!另外,我无法访问DDMS中的data
文件夹。任何建议或帮助都会很明显。
代码
public class DatabaseWrapper extends SQLiteOpenHelper {
//For user table
public static final String FUNTUBE= "User";
public static final String FUNTUBE_ID = "_id";
public static final String FUNTUBE_UNAME = "_username";
public static final String FUNTUBE_EMAIL = "_email";
public static final String FUNTUBE_PASSWORD = "_password";
public static final String FUNTUBE_FNAME="_fname";
public static final String FUNTUBE_LNAME = "_lname";
public static final String FUNTUBE_PHONE="_phone";
public static final String FUNTUBE_COUNTRY = "_country";
public static final String FUNTUBE_GENDER = "_gender";
public static final String FUNTUBE_VIDEOPATH= "_videopath";
public static final String FUNTUBE_BDAY = "_bday";
public static final String FUNTUBE_YEAR = "_year";
public static final String FUNTUBE_INTEREST = "_interest";
public static final String FUNTUBE_RELIGION = "_religion";
public static final String FUNTUBE_ABOUT="_about";
public static final String FUNTUBE_QUOTE="_qoute";
public static final String FUNTUBE_JOB = "_job";
//for UploadFile table
public static final String FUNTUBE_UPLOADFILE= "UploadFile";
public static final String FUNTUBE_UPLOADFILE_ID = "_id";
public static final String FUNTUBE_UPLOADFILE_NAME = "_name";
public static final String FUNTUBE_UPLOADFILE_SIZE = "_size";
public static final String FUNTUBE_UPLOADFILE_CONTENTTYPE = "_contentType";
public static final String FUNTUBE_UPLOADFILE_EXTENSION = "_extension";
public static final String FUNTUBE_UPLOADFILE_CONTENT = "_content";
public static final String FUNTUBE_UPLOADFILE_LABEL = "_label";
public static final String FUNTUBE_UPLOADFILE_DATEUPLOADED = "_dateUploaded";
public static final String FUNTUBE_UPLOADFILE_USERNAME = "_userName";
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
db.execSQL(DATABASE_CREATE1);
}
private static final String DATABASE_NAME = "FunTubeApplication.db";
private static final int DATABASE_VERSION = 1;
// creation SQLite statement
private static final String DATABASE_CREATE = "create table " +FUNTUBE
+ "(" + FUNTUBE_ID + " integer primary key autoincrement, "
+ FUNTUBE_UNAME + " text not null,"
+FUNTUBE_EMAIL + " text not null,"
+FUNTUBE_PASSWORD + " text not null,"
+ FUNTUBE_FNAME + " text not null,"
+FUNTUBE_LNAME + " text not null,"
+FUNTUBE_PHONE + " text not null,"
+ FUNTUBE_COUNTRY + " text not null,"
+FUNTUBE_GENDER + " text not null,"
+FUNTUBE_VIDEOPATH + " text not null,"
+ FUNTUBE_BDAY + " text not null,"
+FUNTUBE_YEAR + " text not null,"
+FUNTUBE_INTEREST + " text not null,"
+ FUNTUBE_RELIGION + " text not null,"
+FUNTUBE_ABOUT + " text not null,"
+FUNTUBE_QUOTE + " text not null,"
+FUNTUBE_JOB+ " text not null)";
private static final String DATABASE_CREATE1 = "create table " +FUNTUBE_UPLOADFILE
+ "(" + FUNTUBE_UPLOADFILE_ID + " integer primary key autoincrement, "
+ FUNTUBE_UPLOADFILE_NAME + " text not null,"
+FUNTUBE_UPLOADFILE_SIZE + " integer not null,"
+ FUNTUBE_UPLOADFILE_CONTENTTYPE + " text not null,"
+FUNTUBE_UPLOADFILE_EXTENSION + " text not null,"
+ FUNTUBE_UPLOADFILE_CONTENT + " text not null,"
+FUNTUBE_UPLOADFILE_LABEL + " text not null,"
+ FUNTUBE_UPLOADFILE_DATEUPLOADED + " date not null,"
+FUNTUBE_UPLOADFILE_USERNAME + " text not null)";
public DatabaseWrapper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if(newVersion>oldVersion) {
db.execSQL("DROP TABLE IF EXISTS " + FUNTUBE);
db.execSQL("DROP TABLE IF EXISTS " + FUNTUBE_UPLOADFILE);
onCreate(db);
}
}
}
答案 0 :(得分:0)
只需将您的DATABASE_VERSION字段更改为2.它将从开头开始删除并重新创建表格。