mardi 29 septembre 2015

Cleanest way of implementing a SUM query in a ContentProvider

The goal is to sum up the amount columns in my SQLite database. Since I am using a ContentProvider to be able to export and share that data in the future, I understand that I am not supposed to directly access the database.
I am unsure which of the four following possibilities is the cleanest and if there are better ways to achieve the above goal.

  • Using the standard query to return all entries and sum them up "manually".
  • Implementing a custom Uri in query that returns a Cursor containing the sum.
  • Implement a custom method in the ContentProdvider that returns the sum as a number.
  • Access the internal database of the ContentProdiver and execute the command "manually".

If you would like to take a look at my code, check out my ContentProvider or the whole code on GitHub.

Aucun commentaire:

Enregistrer un commentaire