Calculating Total Data (row) in SQLite Android

on Sunday, January 6, 2013 | 9:29 PM


Simple tutorial to calculate the amount of data / rows contained in sqlite database in android. The amount of data / row one known to be useful if the data you want inserted already exists, if it exists, it is not necessary to add, if not, then it can be added. But I was not that far, just to check course :)
Android

As we know that to get the results of the query in sqlite in android using Cursor. And as to the general query, that to count the number of rows by using the count (*). So its shape code something like this :

public void count(){
    SQLiteDatabase db = table.getWritableDatabase();
    String count = "SELECT count(*) FROM table";
    Cursor mcursor = db.rawQuery(count, null);
    mcursor.moveToFirst();
    int count = mcursor.getInt(0);
    System.out.println("NUMBER IN DB: " + icount);
}

Share this post :
Calculating Total Data (row) in SQLite Android Published By Technoledge Terima Kasih Telah membaca Calculating Total Data (row) in SQLite Android
Link Published on: 2013-01-06T21:29:00+07:00
Simple tutorial to calculate the amount of data / rows contained in sqlite database in android . The amount of data / row one known to be u... Rating 5 ★★★★★ Reviews 1110
Index »

Android App

 
Copyright © 2013. Technoledge - All Rights Reserved
Proudly powered by Blogger