After the answer by Steve Prentice. This is my implementation:
mydb.sql file in res / raw
CREATE TABLE table1(col1 INTEGER PRIMARY KEY, col2 TEXT); CREATE TABLE table2(col1 INTEGER PRIMARY KEY, col2 TEXT, col3 INTEGER);
Myclass.java
InputStream inputStream = context.getResources().openRawResource(R.raw.mydb); String queries = ""; try { queries = IOUtils.toString(inputStream); } catch (IOException e) { Util.logException(e); } for (String query : queries.split(";")) { db.execSQL(query); }
Androiderson
source share