Android examples for Database:Table Exists
is Exist Database Table
//package com.book2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { public static boolean isExistTable(SQLiteDatabase sqlDb, String tableName) {/*from w w w .j a v a 2s . c o m*/ String sql = "SELECT COUNT(*) as RESULT FROM SQLITE_MASTER WHERE NAME = ?"; Cursor cursor = sqlDb.rawQuery(sql, new String[] { tableName }); int count = 0; if (cursor.moveToFirst()) count = cursor.getInt(cursor.getColumnIndex("RESULT")); if (count >= 1) { cursor.close(); return true; } cursor.close(); return false; } }