public class Utils { private static String DB_PATH = "/data/data/packge-name-app/databases/"; private static String DB_NAME = "database_db"; static public void createDataBase() throws IOException { boolean dbExist = checkDataBase(); if(!dbExist){ try { copyDataBase(); } catch (IOException e) { throw new Error("Error copying database: " + e.getMessage()); } } } static public boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } catch(SQLiteException e){ } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } static public void copyDataBase() throws IOException { File dir = new File(DB_PATH); if (!dir.exists()) dir.mkdir(); InputStream myInput = context.getAssets().open("database_aa"); InputStream myInput2 = context.getAssets().open("database_ab"); InputStream myInput3 = context.getAssets().open("database_ac"); String outFileName = DB_PATH + DB_NAME; OutputStream myOutput = new FileOutputStream(outFileName); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } while ((length = myInput2.read(buffer))>0){ myOutput.write(buffer, 0, length); } while ((length = myInput3.read(buffer))>0){ myOutput.write(buffer, 0, length); } myOutput.flush(); myOutput.close(); myInput.close(); myInput2.close(); } }