Is it better to pass data via intent or query the database when needed?

android, android-intent, database, sql

Solution

As compare to DB Query use Intent.

And another way is, use one common class which will holds your data temporary.

Problem

I am just wondering what would be the better way to handle data in several activities in android. Say I had two activities, A and B, that hold some views. First I load some data from a SQL database and inflate the views in A. Now, I want to start activity B, which uses the same set of data as A did. Is it better to pass the data via Intent (`putExtra()`) and then inflate the views or is it better to query the database again and then inflate. I am not sure about that, because both approaches seem to have their disadvantages: - Querying the database takes more time /more resources - Putting extra data to the intent makes it more complex, because of putting and getting the data (especially when working with more activities) Can someone give me some advice on what is the best practice?

Original source