- Pattern endOfStatement = Pattern.compile(";\\s*(?:--.*)?$");
-
- String line;
- String sqlStatement = null;
- int lineNo = 0;
- while ((line = reader.readLine()) != null) {
- lineNo++;
- if (line.startsWith("--"))
- continue;
- if (line.isEmpty())
- continue;
-
- if (sqlStatement == null)
- sqlStatement = line;
- else
- sqlStatement = sqlStatement.concat(line);
-
- Matcher m = endOfStatement.matcher(line);
- if (!m.find())
- continue;
-
- try {
- db.execSQL(sqlStatement);
- sqlStatement = null;
- }
- catch (Exception e) {
- throw new RuntimeException(
- String.format("Error applying %s, line %d, statement: %s", revFile,
- lineNo, sqlStatement), e);
- }
- }
-
- if (sqlStatement != null)
- throw new RuntimeException(String.format(
- "Error applying %s: EOF after continuation. Line %s, Incomplete " +
- "statement: %s", revFile, lineNo, sqlStatement));
-
- }
- catch (IOException e) {
- throw new RuntimeException(String.format("Error opening raw resource for %s", revFile),
- e);
- }
+ @Override
+ public void onConfigure(SQLiteDatabase db) {
+ super.onConfigure(db);
+ // force a check by Room to ensure everything is OK
+ // TODO: remove when all DB access is via Room
+ DB.get()
+ .compileStatement("SELECT COUNT(*) FROM profiles");