Example usage for android.database DatabaseUtils queryNumEntries

List of usage examples for android.database DatabaseUtils queryNumEntries

Introduction

In this page you can find the example usage for android.database DatabaseUtils queryNumEntries.

Prototype

public static long queryNumEntries(SQLiteDatabase db, String table) 

Source Link

Document

Query the table for the number of rows in the table.

Usage

From source file:Main.java

public static long count() {
    return DatabaseUtils.queryNumEntries(database, TABLE_NAME);
}

From source file:com.panoskrt.dbadapter.DBAdapter.java

public long tableCount(String tableName) {
    long count = DatabaseUtils.queryNumEntries(database, tableName);
    return count;
}

From source file:me.jreilly.JamesTweet.Adapters.TweetDataHelper.java

public Callback<List<Tweet>> callBackMaker(final int mMaxItems, final RecyclerView mRecyclerView,
        final Cursor mCursor, final SQLiteDatabase mTimelineDB, final TweetDataHelper mHelper,
        final SwipeRefreshLayout mSwipeRefreshLayout) {
    final int position = mCursor.getPosition();
    return new Callback<List<Tweet>>() {
        @Override/*from   ww  w .  ja  va 2 s. com*/
        public void success(Result<List<Tweet>> listResult) {

            long numEntries = DatabaseUtils.queryNumEntries(mTimelineDB, "home");
            List<Tweet> list = listResult.data.subList(0, listResult.data.size());

            for (Tweet t : list) {
                try {
                    ContentValues tweetValues = mHelper.getValues(t);
                    mTimelineDB.insertOrThrow("home", null, tweetValues);
                    Log.v("NEW CONTEXT", "Added Tweet Tweets!");

                } catch (Exception te) {
                    Log.e("NEW CONTEXT", "Exception: " + te);
                }

            }

            int rowLimit = 50;

            if (DatabaseUtils.queryNumEntries(mTimelineDB, "home") > rowLimit) {
                String deleteQuery = "DELETE FROM home WHERE " + BaseColumns._ID + " NOT IN " + "(SELECT "
                        + BaseColumns._ID + " FROM home ORDER BY " + "update_time DESC " + "limit " + rowLimit
                        + ")";
                mTimelineDB.execSQL(deleteQuery);
                Log.v("NEW CONTEXT", "Deleteing Tweets!");
            }
            mRecyclerView.getAdapter().notifyDataSetChanged();
            if (mSwipeRefreshLayout != null) {
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                mRecyclerView.smoothScrollToPosition(position);
            }

            Log.v("NEW CONTEXT", "All done!");

        }

        @Override
        public void failure(TwitterException e) {
            Log.e("NEW CONTEXT", "Exception " + e);

        }
    };
}

From source file:se.kth.ssvl.tslab.bytewalla.androiddtn.servlib.storage.SQLiteImplementation.java

public int getTableSize(String table) {
    return (int) DatabaseUtils.queryNumEntries(db, table);
}