-1

I have my android app . My requirement is that it should read all incoming messages from inbox , filter it based on some criteria and persist the filtered sms in the SQLite DB of the app. All this should happen even if the app is closed i.e. 24*7

Please suggest some good way which should have less performance impact on android battery and memory consumption .

rohitraj
  • 46
  • 4
  • If you want minimal extraneous battery consumption, then [query the inbox](http://stackoverflow.com/questions/848728/how-can-i-read-sms-messages-from-the-inbox-programmatically-in-android) when the user runs your app, and save the needed messages all at once to your app's database then. If you really need to get messages as they arrive, then register an appropriate Receiver in your manifest, as shown in [this post](http://stackoverflow.com/questions/7089313/android-listen-for-incoming-sms-messages), and save the incoming message that way. – Mike M. Jul 26 '16 at 13:38

1 Answers1

0

Register a Broadcast receiver to listen for incoming messages. And in Broadcast Receiver's onReceive method, start this db operation in a separate service(Preferably Intent Service).

Dont start processing the sms inside onReceive method. Do this by starting a new Service, which does its task of processing and stops itself.

prashant
  • 199
  • 2
  • 7