Java tutorial
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; public class Main { public static final String DATABASE_NAME = "DBFinDeMes"; public static String DB_PATH = ""; /** * Check if the database exist * * @return true if it exists, false if it doesn't */ public static boolean checkDataBase(Context context) { SQLiteDatabase checkDB = null; int count = 0; try { if (android.os.Build.VERSION.SDK_INT >= 17) { DB_PATH = context.getApplicationInfo().dataDir + "/databases/"; } else { DB_PATH = "/data/data/" + context.getPackageName() + "/databases/"; } checkDB = SQLiteDatabase.openDatabase(DB_PATH + DATABASE_NAME, null, SQLiteDatabase.OPEN_READONLY); String selectRegistros = "SELECT COUNT(*) FROM Grupo_Gastos"; Cursor mCursor = checkDB.query(true, "Grupo_Gastos", new String[] { "_id" }, null, null, null, null, null, null); count = mCursor.getCount(); checkDB.close(); } catch (SQLiteException e) { // database doesn't exist yet. return false; } return count > 0; } }