I am trying to make a dailypedea app which gives notification message daily. I used SQLite and i have made a field date in which i have Entered dates. When System date matches String date in database, it displays the corresponding message. Problem however is, Message is not automatically notified i.e. When the date changes, notification is not automatically popped. I made the following program but it is not effecient. It has two cursor and when date matches with system's date, Corresponding cursor shows message. When last row is reached, I redirect it to first and it goes on and on.Is there any other efficient means to notify user at a particular conditionpackage com.example.prince.notidaily;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.ContentValues;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.support.v7.app.NotificationCompat;import android.util.Log;import android.widget.Toast;import java.util.Calendar;public class MainActivity extends AppCompatActivity {   // Date date;      ///description demo    String message;    Calendar c;    int flag=0;    int day,month,year;    String date;   // Notification notification;   // PendingIntent pendingIntent;    //Intent intent;   // NotificationManager notificationManager;   Notification.Builder nBuilder=null;    NotificationCompat.Builder notification;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        c= Calendar.getInstance();        SQLiteDatabase notidb=openOrCreateDatabase(notidb10, Context.MODE_PRIVATE,null);        Toast.makeText(getApplicationContext(), db created, Toast.LENGTH_LONG).show();        day=c.get(Calendar.DAY_OF_MONTH);        month=c.get(Calendar.MONTH);        ++month;        year=c.get(Calendar.YEAR);        date = +month+/+day+/+year;        Toast.makeText(getApplicationContext(), date is+date, Toast.LENGTH_LONG).show();        String create=create table if not exists notitable2(date TEXT,message TEXT);        notidb.execSQL(create);        Toast.makeText(getApplicationContext(), notitable2 table created, Toast.LENGTH_LONG).show();        ContentValues values=new ContentValues();        values.put(date,7/21/2017);        values.put(message,get to work);        notidb.insert(notitable2,null,values);        Toast.makeText(getApplicationContext(),first entry, Toast.LENGTH_LONG).show();        values.put(date,7/22/2017);        values.put(message, reach home);        notidb.insert(notitable2,null,values);        Toast.makeText(getApplicationContext(), second entry, Toast.LENGTH_LONG).show();        values.put(date,7/23/2017);        values.put(message,science the shit out of it);        notidb.insert(notitable2,null,values);        Toast.makeText(getApplicationContext(), third entry, Toast.LENGTH_LONG).show();        values.put(date,7/24/2017);        values.put(message,get to work yet again);        notidb.insert(notitable2,null,values);        Toast.makeText(getApplicationContext(), fourth entry, Toast.LENGTH_LONG).show();        String cols[]={date};        String msg[]={message};        Cursor c=notidb.query(notitable2,cols, null, null, null, null, null);        Cursor d=notidb.query(notitable2,msg,null, null, null, null, null);      //  c.getPosition        // c.getString();        //d.moveToNext();        d.moveToNext();        Log.e(check,d.getString(0));         while(c.moveToNext()){               int x= date.compareTo(c.getString(0));           // Toast.makeText(MainActivity.this, +x,Toast.LENGTH_SHORT).show();             if(x!=0){                 d.moveToNext();                 continue;             }            if(x==0){               // Toast.makeText(MainActivity.this,d.getString(0),Toast.LENGTH_SHORT).show();                Intent intent=new Intent(MainActivity.this,MainActivity.class);                PendingIntent pendingIntent=PendingIntent.getActivity(MainActivity.this,0,intent,0);                Notification notification=new Notification.Builder(MainActivity.this)                        .setContentTitle(Noti Daily)                        .setContentText(d.getString(0))                        .setSmallIcon(R.drawable.a)                        .setContentIntent(pendingIntent).getNotification();                notification.flags=Notification.FLAG_AUTO_CANCEL;                NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);                notificationManager.notify(0,notification);                    c.moveToFirst();                    d.moveToFirst();                    d.moveToNext();                continue;            }        }       // notificationManager.notify(0,notification);    }}
Android App which notifies User Daily
java;android