Android examples for Database:Database Open
Get Database version
/*// www . j ava 2 s .c o m * Copyright 2011 Giles Malet. * * This file is part of GRTransit. * * GRTransit is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRTransit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRTransit. If not, see <http://www.gnu.org/licenses/>. */ //package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; public class Main { private static String DB_PATH = null; private static int DB_VERSION = -1; private static SQLiteDatabase DB = null; public static SQLiteDatabase ReadableDB() { if (DB == null) { try { DB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); // Stash the version final Cursor csr = DB.rawQuery("PRAGMA user_version", null); csr.moveToPosition(0); DB_VERSION = csr.getInt(0); csr.close(); } catch (final SQLiteException e) { // bah } } return DB; } }