androiddatabaseperformanceandroid-sms

Should I store messages in my database or query the system SMS database everytime?


I am developing an SMS app. I am getting messages from the Android Database every time user opens the App.

On a device with around 100 messages, it works fine. But with a device with 10,000 messages the app takes around 20 seconds to display the list after getting all the information.

To solve this, I am thinking about three possible options here:

  1. Should I consider saving all the data to my own database? Will it make it faster?
  2. Should I get some messages first, and then the rest in the background?
  3. Any other option you might suggest.

Thanks in advance.


Solution

  • Below are the answers of your question

    1. Should I consider saving all the data to my own database? Will it make it faster?

    No, don't do that. This will not make it faster. Same response you will get.

    2. Should I get some messages first, and then the rest in the background?

    You can do this, but there is no need to do this to get all messages in background.Because User can see limited number of messages and chances are he will not see all messages down the bottom. So it will be useless to get those in background (untill or unless there is a business requirement)

    Any other option you might suggest.

    Yes, you need to implement pagination and need to keep track how many messages are needed to be loaded first time and while user scrolls then get more messages. In this case you need to keep track your own about how many messages you have already loaded and how many more you want to load. TO achive this, you will be required to implement PULL TO REFERESH mechanism of android. And a lot of tutorials can be found over the web.

    Hope that answers your question.