How can I check if the cursor is empty or if there are any contacts in the contact list of the phone? When database is not empty then it call my Shake Service class but this logic does not works
Cursor mCursor = db.rawQuery("SELECT * FROM details", null);
Boolean rowExists;
if (mCursor.moveToFirst())
{
Intent i_startservice = new Intent(MainActivity.this, ShakeService.class);
startService(i_startservice);
rowExists = true;
} else
{
Toast.makeText(this,"Databse is Empty",Toast.LENGTH_SHORT).show();
rowExists = false;
}
Background services will no longer be implementable after Android O. So, please check with the documentation about Foreground Services before you proceed. Happy hacking!