我的项目中已经有两个数据库,想要为某些任务创建一个新数据库,但没有创建数据库我认为我的代码做错了,请帮我解决这个问题。谢谢。
public class LikeShareDbHelper extends SQLiteOpenHelper{
static final int version = 10;
static final String dbName = "LikeShareDB";
static final String LikeAndShare = "LikeAndShareTable";
static final String coluId = "id";
static final String coluTask = "Task_id";
static final String coluLike = "TLike";
static final String coluComment = "TComment";
static final String coluTSahre = "Tshare";
static final String coluMySelf = "mtself";
private static final String DATABASE_CREATE = "CREATE TABLE "
+ LikeAndShare + " (" + coluId
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + coluTask + " TEXT, "
+ coluLike + " TEXT, " + coluComment + " TEXT, " + coluTSahre
+ " Text, " + coluMySelf + " TEXT );";
SQLiteDatabase db;
private LikeShareDbHelper dbHelper;
public LikeShareDbHelper(Context context) {
super(context, dbName, null, version);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXISTS " + LikeAndShare);
onCreate(db);
}
public LikeShareDbHelper open() throws SQLException {
db = dbHelper.getWritableDatabase();
// dbHelper.open();
return this;
}
// ---closes the database---
public void close() {
dbHelper.close();
}
}