- Pattern continuation = Pattern.compile("\\\\\\s*$");
-
- String line;
- String sqlStatement = null;
- boolean eolPending;
- int lineNo = 0;
- while ((line = reader.readLine()) != null) {
- lineNo++;
- if (line.startsWith("--"))
- continue;
- if (line.isEmpty())
- continue;
-
- Matcher m = continuation.matcher(line);
- eolPending = false;
- if (m.find()) {
- line = m.replaceFirst("");
- eolPending = true;
- }
-
- if (sqlStatement == null)
- sqlStatement = line;
- else
- sqlStatement = sqlStatement.concat(line);
-
- if (eolPending)
- 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", revFile));
-
- }
- 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");