Search in sources :

Example 1 with UnknownDatabaseVersionException

use of com.ichi2.libanki.exception.UnknownDatabaseVersionException in project Anki-Android by ankidroid.

the class Storage method getDatabaseVersion.

/**
 * Helper method for when the collection can't be opened
 */
public static int getDatabaseVersion(String path) throws UnknownDatabaseVersionException {
    try {
        if (!new File(path).exists()) {
            throw new UnknownDatabaseVersionException(new FileNotFoundException(path));
        }
        DB db = new DB(path);
        int result = db.queryScalar("SELECT ver FROM col");
        db.close();
        return result;
    } catch (Exception e) {
        Timber.w(e, "Can't open database");
        throw new UnknownDatabaseVersionException(e);
    }
}
Also used : UnknownDatabaseVersionException(com.ichi2.libanki.exception.UnknownDatabaseVersionException) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) ConfirmModSchemaException(com.ichi2.anki.exception.ConfirmModSchemaException) FileNotFoundException(java.io.FileNotFoundException) JSONException(com.ichi2.utils.JSONException) UnknownDatabaseVersionException(com.ichi2.libanki.exception.UnknownDatabaseVersionException)

Aggregations

ConfirmModSchemaException (com.ichi2.anki.exception.ConfirmModSchemaException)1 UnknownDatabaseVersionException (com.ichi2.libanki.exception.UnknownDatabaseVersionException)1 JSONException (com.ichi2.utils.JSONException)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1