Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

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

public class Main {
    private static final String DEPRECATED_DATABASE_NAME = "wordpress";
    private static final String DEPRECATED_POSTS_TABLE = "posts";

    public static boolean hasDraftsToMigrate(Context context) {
        try {
            SQLiteDatabase db = context.openOrCreateDatabase(DEPRECATED_DATABASE_NAME, 0, null);

            String byString = "localDraft=1 OR isLocalChange=1";
            Cursor c = db.query(DEPRECATED_POSTS_TABLE, null, byString, null, null, null, null);
            if (c.getCount() > 0) {
                c.close();
                return true;
            }
            c.close();
            return false;
        } catch (SQLException e) {
            return false;
        }
    }
}