以下は私のデータベースコードで、バージョン番号を変更してアップグレードしようとしていますが、テーブルを実行すると再作成または変更されません...コードに何か問題がありますplz help
public class DBHelper extends SQLiteOpenHelper {
public static final int db_version = 1;
private static final String CL_CITY = null;
public static final String COL_NAME = "pName";
//private static final String TABLE_NAME = CL_CITY;
public static String TAG = DBHelper.class.getName();
public static String DB_PATH = "data/data/org.clock/database/";
private static String STATUS= "STATUS";
private static String dbName = "clock.db";
private static final String STRING_ALTER = "ALTER TABLE "+CL_CITY+" ADD "+STATUS+" STATUS";
protected SQLiteDatabase dataBase;
protected Context context;
//private Context context;
private static SQLiteDatabase checkDB = null;
public DBHelper(Context context, String dbName) {
super(context, dbName, null, 34);
//this.dbName = dbName;
this.context = context;
}
public void createDb() throws IOException {
boolean dbExist = checkDataBase();
Log.d(TAG, "DBChecking............ dbExist : " + dbExist);
if (!dbExist) {
this.getReadableDatabase();
try {
copyDataBase();
} catch (IOException e) {
Log.d(TAG, "Error cloneing database" + e);
}
}
}
private boolean checkDataBase() {
try {
if(checkDB == null){
String path = DB_PATH + dbName;
Log.d(TAG, "checkDataBase path=" + path);
checkDB = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY);
}
} catch (SQLiteException e) {
Log.e(TAG, "DBChecking............ ", e);
}
/*if (checkDB != null) {
checkDB.close();
}*/
return checkDB != null ? true : false;
}
private void copyDataBase() throws IOException {
Log.i(TAG, "copyDataBase database...");
File file = new File(DB_PATH);
Log.i(TAG, "cloneDataBase file=" + file);
file.mkdirs();
InputStream dbInput = context.getAssets().open(dbName);
String outPutFile = DB_PATH + dbName;
Log.i(TAG, "copyDataBase outPutFile=" + outPutFile);
OutputStream dbOutPut = new FileOutputStream(outPutFile);
byte[] buffer = new byte[1024];
Log.i(TAG, "copyDataBase buffer=" + buffer);
int length;
while ((length = dbInput.read(buffer)) > 0) {
dbOutPut.write(buffer, 0, length);
}
dbOutPut.flush();
dbOutPut.close();
dbInput.close();
}
public void openDb() throws SQLException {
String dbPath = DB_PATH + dbName;
dataBase = SQLiteDatabase.openDatabase(dbPath, null,
SQLiteDatabase.OPEN_READWRITE);
}
@Override
public synchronized void close() {
if (dataBase != null)
dataBase.close();
super.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion > oldVersion){
//db.execSQL("CREATE TABLE "+"staff"+" (_id INTEGER PRIMARY KEY AUTOINCREMENT, "
// +COL_NAME+" TEXT);");
db.execSQL("STRING_ALTER ");
}
}}