Intent.putExtra vs. getJSONObject - Android
I have a question regarding the performance of an application.
I have an object in an external database and I have already extracted all the data about it from the database, including unique id. I start a new activity, but I want to use the same info 开发者_JAVA技巧for the same object in the new activity - what will be faster - include all the strings I already obtained via getJSONObject
as extras for the intent or include just the object's id as an intent extra
and make a new query to the database, receive the response and obtain the json response once again?
And how could I test what method is faster than the other?
Database query is a more expensive action than just passing the strings in the intent (especially if you pass the JSON string itself, not each string inside it) so if you're going to use the same data, I think you should pass it with the intent, however, this is not something that is hard to test and measure.
精彩评论