Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Main {
    /**
     *  Check if we have the schema information for a model in our database
     * @param model the model we want to check
     * @param db a readable link to our database
     * @return if the model schema exists
     */
    public static synchronized boolean schemaCheck(SQLiteDatabase db, String model) {
        Cursor cursor = db.rawQuery("select DISTINCT tbl_name from sqlite_master where tbl_name = '" + model + "'",
                null);
        if (cursor != null) {
            if (cursor.getCount() > 0) {
                cursor.close();
                return true;
            }
            cursor.close();
        }
        return false;
    }
}