SQLite
MesaSQLite可以幫助讀入及編輯*.sqlite
讀入已存在的sqlite
讀入已存在的sqlite
private static final String DB_PATH = "/data/data/com.xxx.xxx/databases/"; private static final String DB_NAME = "xxx.sqlite"; SQLiteDatabase database = this.getReadableDatabase(); try { //Open your local db as the input stream InputStream myInput = ctx.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } catch (IOException e) { throw new Error("Error copying database"); } database.close();
Comments
Post a Comment