Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With the understanding of your question in place, I am pretty certain there is a fault in fetchAllGeneralRemindersByDefault(). It is returning en empty cursor. If this is because of the code, or the database being empty, I cannot tell.</p> <p>Suggestion to code refactor:</p> <pre><code>public void onReceive(Context context, Intent intent){ ReminderManager reminderMgr = new ReminderManager(context); TaskDatabase dbHelper = new TaskDatabase(context); dbHelper.open(); // returns an empty cursor at index -1 (that is normal behaviour for cursors) Cursor cursor = dbHelper.fetchAllGeneralRemindersByDefault(); if(cursor != null &amp;&amp; cursor.size() &gt; 0){ // added check int rowIdColumnIndex = cursor.getColumnIndex(TaskDatabase.KEY_ROWID); int dateTimeColumnIndex = cursor.getColumnIndex(TaskDatabase.KEY_DATE_TIME); // when you called moveToNext on the empty cursor // it corresponds to calling list.get(0) on an empty ArrayList while(cursor.moveToNext()){ Log.d(TAG, "Adding alarm from boot."); Log.d(TAG, "Row Id Column Index - " + rowIdColumnIndex); Log.d(TAG, "Date Time Column Index - " + dateTimeColumnIndex); Long rowId = cursor.getLong(rowIdColumnIndex); String dateTime = cursor.getString(dateTimeColumnIndex); Calendar cal = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat(TaskEdit.DATE_TIME_FORMAT); try{ java.util.Date date = format.parse(dateTime); cal.setTime(date); reminderMgr.setReminder(rowId, cal); }catch(java.text.ParseException e){ Log.e("OnBootReceiver", e.getMessage(), e); } } } else { Log.e("OnBootReceiver", "fetchAllGeneralRemindersByDefault() returned empty cursor"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload