title: app crashes when alarm triggers if app is closed
body: <p>Get Exception :</p>
  
  <blockquote>
    <p>Caused by: android.database.sqlite.SQLiteException: no such table:
    TABLE_USER_RITUALS (code 1): , while compiling: Select * from
    TABLE_USER_RITUALS where USER_NAME = 'vxfbb' and RITUAL_NAME =
    'Morning Routine'</p>
  </blockquote>
  
  <p>But the database is exists as the code works fine if the app is opened in background, it got crashed when app is removed from the background</p>
  
  <p>Broadcast Receiver Class:</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver
  {
  
      String h_id, habit, habit_desc, habit_time;
      //public static Ringtone ringtone;
  
      @Override
      public void onReceive(Context mContext, Intent arg1) 
      {
          String selectedRitual = arg1.getExtras().getString(AppsConstant.SELECTED_RITUAL);
          String userName = arg1.getExtras().getString(AppsConstant.user_name);
  
          // Enable {@code SampleBootReceiver} to automatically restart the alarm when the
          // device is rebooted.
          ComponentName receiver = new ComponentName(mContext, SampleBootReceiver.class);
          PackageManager pm = mContext.getPackageManager();
  
          pm.setComponentEnabledSetting(receiver,
                  PackageManager.COMPONENT_ENABLED_STATE_ENABLED,PackageManager.DONT_KILL_APP); 
  
          //get data from database        
          GetData getData = new GetData();
          UserRitualModel userReminderSetting  = getData.getRitualsDetails(userName, selectedRitual);
          int isfullScreen = userReminderSetting.getNotificationStyle();
          int ringInSilent = userReminderSetting.getRingInSilent();
  
          if(ringInSilent ==TableAttributes.ON)
          {
              final AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
              int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
  
              audioManager.setStreamVolume(AudioManager.STREAM_ALARM, maxVolume,AudioManager.FLAG_ALLOW_RINGER_MODES); 
          }
  
  
          Intent i;
          if(isfullScreen==TableAttributes.ON)
          {
                i = new Intent(mContext, ReminderFullScreen.class);
          }
          else
          {
              i = new Intent(mContext, Reminder.class);  
          }
         // i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          i.putExtra(AppsConstant.SELECTED_RITUAL, selectedRitual);
          i.putExtra(AppsConstant.user_name, userName);
  
          mContext.getApplicationContext().startActivity(i);
  
      }
  }
  </code></pre>