Android examples for Database:Cursor
is database Table Existed via cursor
//package com.book2s; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { public static boolean isTableExisted(Context context, String tableName) { SQLiteDatabase db = getDatabase(context); Cursor cursor = db.query(false, "sqlite_master", null, "tbl_name='" + tableName + "'", null, null, null, null, null); boolean existed = false; if (cursor != null && cursor.getCount() > 0) { existed = true;//from ww w. j a v a2 s . c om } if (cursor != null) { cursor.close(); } db.close(); return existed; } public static SQLiteDatabase getDatabase(Context context) { return context.openOrCreateDatabase("tomato.db", Context.MODE_PRIVATE, null); } }