Upgrading database on Application Update
===

I am having a database and i want to change that database on next update of my application ..But i dont want to loss the current data in database(in Application directory)..I have to copy that data in to new database and delete the old database..How can i achieve that?Is there any other idea about that let me know...


thanks in advance..


this is my current database code...

    public class DbUtils {
	public static String DB_PATH;
	private String DB_NAME;
	File dbDir;
	private SQLiteDatabase dataBase;
	public DbUtils(File fileDirectory, String sqliteFileName) {

		this.DB_NAME = sqliteFileName;
		dbDir = fileDirectory;
	}

	public void createDatabaseIfNotExists(Context context) throws IOException {
		boolean createDb = false;
		
		File dbFile = new File(dbDir.getAbsolutePath() + "/" + DB_NAME);
		DB_PATH = dbFile.getAbsolutePath();

		if (!dbDir.exists()) {
			dbDir.mkdir();
			createDb = true;
		} else if (!dbFile.exists()) {
			createDb = true;
		} else {
			boolean doUpgrade = false;

			if (doUpgrade) {
				dbFile.delete();
				createDb = true;
			}
		}

		if (createDb) {
			InputStream myInput = context.getAssets().open(DB_NAME);
			OutputStream myOutput = new FileOutputStream(dbFile);
			byte[] buffer = new byte[1024];
			int length;
			while ((length = myInput.read(buffer)) > 0) {
				myOutput.write(buffer, 0, length);
			}

			myOutput.flush();
			myOutput.close();
			myInput.close();
		}
	}

	public SQLiteDatabase getStaticDb() {
		return dataBase = SQLiteDatabase.openDatabase(DB_PATH, null,
				SQLiteDatabase.OPEN_READWRITE);
	}
	
	public void closeDataBase(){
		if(dataBase!=null && dataBase.isOpen()){
			dataBase.close();
		}
	}

     }