Reloading data intensive activities in android
I load lots开发者_开发技巧 of contents(images,text,etc..) from server and displayed it on the listview in the activity-A. On clicking the any row of the listview, I finish the activity and release all the variables(to avoid memory problems) and open another activity-B and display the content in detailed format.
When hitting back from activity-B, obviously it again loads content from the server. Is there any other solution instead of finishing activity to avoid again loading from the server but it should not come up with the memory problems?
Finishing activity A is totally unnecessary in your case as you want to return to it. It's good to think about saving memory but is not worth it if you have to reload a big bunch of data from a server again.
Instead store the data you loaded from the server some where on the device and don't finish activity A. When you then press the back button on Activity B, Activity B will be finished and Activity A will be resumed (onResume() will be executed), there you can now reload the data you previously loaded from the server from the device.
You can use lazy-loading concept to achieve this. Click here
Thanks Deepak
You could cache your data which is being downloaded from the internet.
Consider storing data to a SQLite contentProvider or directly to the SDcard. However make sure to clear any old data when you load Activity-A from the internet again.
精彩评论