ray an
ray an

Reputation: 1288

Sqlite Database and Broadcast Receiver

Is it a good idea to access SQLite Database inside the Broadcast Receiver and perform operations (say reading from it and displaying a toast or changing the UI etc) on it.

Can Android kill my Receiver while performing these operations? (if those operations are lengthy)

What's the right way of doing the above operations?

Upvotes: 0

Views: 639

Answers (1)

S Haque
S Haque

Reputation: 7281

A broadcast receiver (receiver) is an Android component which allows you to register for system or application events. All registered receivers for an event are notified by the Android runtime once this event happens. So BroadcastReceiver is not recommended for doing this kind of lengthy process. You can start a Service from that BroadcastReceiver to access your Database.

Upvotes: 1

Related Questions