Android OrmLite pre-populate database
Just wanted to post my solution for anyone who might need it
try { tableDAO.updateRaw("DELETE FROM table"); InputStream is = getResources().openRawResource(R.raw.populate_db); DataInputStream in = new DataInputStream(is); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { tableDAO.updateRaw(strLine); } in.close();} catch (Exception e) { e.printStackTrace();}
Good one Joe. I think your idea of the executeRaw()
is close but use updateRaw()
instead. Update handles INSERT
, DELETE
, and UPDATE
statements.
You should call TableUtils
to create your schema first of course:
Hope this helps. You may want to use the mailing list for questions in the future: