1

I'm working on a music app for android. I'm creating my own music database since the android Mediastore doesn't have all the fields I need. I'm planning to update the database as soon as the Mediastore changes since updating the database on every app launch makes the app very slow to start.

Is this the right approach? Also please guide me on how can I listen to changes in the Audio files data in Mediatore, regardless of whether my app is running or not.?

I've read this answer but it's applicable only when my app is running. How do I do this even when the app is not running? Also the answer is more than 3 years old so things might have changed. I believe I'll need to use BroadcastReceiver but I'm not sure how to go about it. I'm using Realm for database.

Any pointers would be really helpful.

Community
  • 1
  • 1
Anjani
  • 1,533
  • 3
  • 15
  • 26
  • 1
    So, as per the link given, run it inside service. – Nigam Patro Dec 18 '15 at 09:39
  • I agree with @NigamPatro either you can use service to update your database or if the operation is long you can use intentservice. Plus if the the changes happened is important to launch your app then you can update the changes locally and in background you can update database – Preethi Rao Dec 18 '15 at 09:51
  • You mean I create a service that keeps running in the background even when the app is not running? If yes, then that I think would be really bad for performance and on the battery as well. If no, then please elaborate a little. – Anjani Dec 18 '15 at 09:59

0 Answers0