0

So i would like to have one aspect of my app that does a Query into a pre-loaded database using SQLiteAssetHelper be repeated each day at the same time and according to real time, regardless if the App is on.

I saw that AlarmManager uses all the functions that I would want for the daily re-query but it asks for a PendingIntent in its parameters and I can't put a simple Cursor in there... I tried (feels dumb). I wanted to know if someone could help me out with how to use AlarmManager (And i saw the Calander methods of setting up the specified time according to the System Clock and i kind of get it but help with that would be great too!) or some other way to have this one line of code executed at the same time every day and not dumped or ignored by the Android Garbage Collector...

Here is the Code that I want to Execute:

private String OpenningDatabaseMethod(String GenreSelected) {
    openDB();
    OpenningcursorQuery = databaseClass.OpenningqueryMethod(GenreSelected);
    OpenningcursorQuery.moveToFirst();
    String StoryPicked = OpenningcursorQuery.getString(OpenningcursorQuery.getColumnIndex("Story"));
    return StoryPicked;
}

And it communicates with the Database Class to get the query back and apply it to a textview...

Any help is MUCH appreciated....Thank You!!!!

KellysOnTop23
  • 1,325
  • 2
  • 15
  • 34
  • As it stands now, your question is not really answerable. Take a look at code samples such as this one: http://stackoverflow.com/questions/1082437/android-alarmmanager/1082836#1082836 Basically, you will need and `Intent` and a `PendingIntent`, and a valid `Context`. You would need to use data extracted from your `Cursor`, not the `Cursor` itself. – Daniel Nugent Apr 11 '15 at 18:09
  • So how would I add the data extracted from the cursor to the pending intent? would i use `putExtra` in an intent and then use that in the pending's parameter? – KellysOnTop23 Apr 11 '15 at 19:35
  • Yep, exactly. Use `putExtra()` on the `Intent` that you give to `PendingIntent.getBroadcast()` or `PendingIntent.getActivity()`. – Daniel Nugent Apr 11 '15 at 19:49

0 Answers0