Android examples for Database:Database Connection
check Database
//package com.book2s; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.util.Log; public class Main { public static String DATABASE_PATH; public final static String DB_NAME = "Fly.sqlite"; public static boolean checkDatabase() { SQLiteDatabase db = null;/* w w w . j a v a 2 s. com*/ try { String databaseFilename = DATABASE_PATH + DB_NAME; db = SQLiteDatabase.openDatabase(databaseFilename, null, SQLiteDatabase.OPEN_READWRITE); db.rawQuery("select count(1) from Flyfight", null); } catch (SQLiteException e) { db = null; } if (db != null) { db.close(); } boolean exists = ((db != null) ? true : false); return exists; } }