public static void logTableDump(SQLiteDatabase db, String tablename) { Cursor cursor = db.query(tablename, null, null, null, null, null, null); try { String dump = DatabaseUtils.dumpCursorToString(cursor); DaoLog.d(dump); } finally { cursor.close(); } }
/** * Executes the given SQL asset in the given database (SQL file should be UTF-8). The database * file may contain multiple SQL statements. Statements are split using a simple regular * expression (something like "semicolon before a line break"), not by analyzing the SQL syntax. * This will work for many SQL files, but check yours. * * @return number of statements executed. */ public static int executeSqlScript( Context context, SQLiteDatabase db, String assetFilename, boolean transactional) throws IOException { byte[] bytes = readAsset(context, assetFilename); String sql = new String(bytes, "UTF-8"); String[] lines = sql.split(";(\\s)*[\n\r]"); int count; if (transactional) { count = executeSqlStatementsInTx(db, lines); } else { count = executeSqlStatements(db, lines); } DaoLog.i("Executed " + count + " statements from SQL script '" + assetFilename + "'"); return count; }