public boolean isDatabaseIntegrityOk(){
  acquireReference();
  try {
    List<Pair<String,String>> attachedDbs=null;
    try {
      attachedDbs=getAttachedDbs();
      if (attachedDbs == null) {
        throw new IllegalStateException("databaselist for: " + getPath() + " couldn't "+ "be retrieved. probably because the database is closed");
      }
    }
 catch (    SQLiteException e) {
      attachedDbs=new ArrayList<Pair<String,String>>();
      attachedDbs.add(new Pair<String,String>("main",getPath()));
    }
    for (int i=0; i < attachedDbs.size(); i++) {
      Pair<String,String> p=attachedDbs.get(i);
      SQLiteStatement prog=null;
      try {
        prog=compileStatement("PRAGMA " + p.first + ".integrity_check(1);");
        String rslt=prog.simpleQueryForString();
        if (!rslt.equalsIgnoreCase("ok")) {
          Log.e(TAG,"PRAGMA integrity_check on " + p.second + " returned: "+ rslt);
          return false;
        }
      }
  finally {
        if (prog != null)         prog.close();
      }
    }
  }
  finally {
    releaseReference();
  }
  return true;
}

public boolean isDatabaseIntegrityOk ( ) { acquireReference ( ) ; try { List < Pair < String , String > > attachedDbs = null ; try { attachedDbs = getAttachedDbs ( ) ; if ( attachedDbs == null ) { throw new IllegalStateException ( "databaselist for: " + getPath ( ) + " couldn't " + "be retrieved. probably because the database is closed" ) ; } } catch ( SQLiteException e ) { attachedDbs = new ArrayList < Pair < String , String > > ( ) ; attachedDbs . add ( new Pair < String , String > ( "main" , getPath ( ) ) ) ; } for ( int i = 0 ; i < attachedDbs . size ( ) ; i ++ ) { Pair < String , String > p = attachedDbs . get ( i ) ; SQLiteStatement prog = null ; try { prog = compileStatement ( "PRAGMA " + p . first + ".integrity_check(1);" ) ; String rslt = prog . simpleQueryForString ( ) ; if ( ! rslt . equalsIgnoreCase ( "ok" ) ) { Log . e ( TAG , "PRAGMA integrity_check on " + p . second + " returned: " + rslt ) ; return false ; } } finally { if ( prog != null ) prog . close ( ) ; } } } finally { releaseReference ( ) ; } return true ; }
runs ' pragma integrity_check ' on the given database ( and all the attached databases ) and returns true if the given database ( and all its attached databases ) pass integrity_check , false otherwise . < p > if the result is false , then this method logs the errors reported by the integrity_check command execution . < p > note that ' pragma integrity_check ' on a database can take a long time .
