1

i am developing a alarm application using BroadcastReceiver. Here i need to check whether the alarm is on or off from the database. So i need to check the status of the alarm when the broadcast event came. I have to put the database access code in BroadcastReceiver class onReceive() method. Here suggest me if there is any way to access the data from the BroadcastReceiver

thanks in advance

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
raghumudem
  • 747
  • 1
  • 9
  • 17

1 Answers1

-1

There is no real problem accessing the DB from the BroadcashReceiver. You will need the context, which you have as part of the BroadcastReceiver onReceive method signature and that's it. If you're facing a specific problem, please tell us what it is

IncrediApp
  • 10,303
  • 2
  • 33
  • 24
  • Here i can not give the context like alarmDB = this.openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null); here what can i use instead of this to represent the context – raghumudem Sep 06 '11 at 13:35
  • onReceive receives the context as a parameter. Just call: context.openOrCreateDatabase ... – IncrediApp Sep 06 '11 at 13:46
  • Thanks i confused about the context.If u don't mine can u clarify what is context. – raghumudem Sep 06 '11 at 14:04
  • 1
    You actually shouldn't use openOrCreateDatabase directly... You should use SQliteOpenHelper. Look at this link to understand how to use it. http://developer.android.com/guide/topics/data/data-storage.html – IncrediApp Sep 06 '11 at 14:10
  • i can`t delete entries in sqlite database. – KOUSIK daniel Aug 07 '15 at 16:35