i'm working sqlite.i want to check if table is empty.i wrote some code but my code does not working perfect this is a my DatabaseHelper code (function)
public void CheckGenderTableEmpty() {
String count = "SELECT * FROM Gender";
Cursor mcursor = db.rawQuery(count, null);
mcursor.moveToFirst();
if (mcursor.getCount() != 0) {
if (!mcursor.isClosed())
mcursor.close();
Log.e("is not empty", "is not empty");
} else {
if (!mcursor.isClosed())
mcursor.close();
Log.e(" empty", "empty");
}
}
as i said my code does not working perfect.first time my table is empty and i can't show log message about empty and i call my function activity like this..
db_helper=new DatabaseHelper(getApplicationContext());
db_helper.CheckGenderTableEmpty();
how i can check if database is empty in activity?
for example
if(db_helper.CheckGenderTableEmpty() is empty)
{
do something
}
else
{
}
if anyone knows solution please help me
Aucun commentaire:
Enregistrer un commentaire