Search code examples
androidperformancedata-processing

How to send A List between activities through intents in android if the size of list is too big


What is the best way to send big amount of data through intents from one activity to another. Should I split the data into small amounts and send them one by one through intents. If It takes a lot of intents such as around 1000 intents to send the entire data, will it be still efficient for android devices.

The process is sender activity will split the entire list, then send data one by one in intent body. In the receiving site, receiver activity will gather data one by one and rebuild the entire list. The problem here is If it takes too much intents (around 1000 intents) to send the entire list, will it still work in general android devices. Will it cause any performance issue?


Solution

  • I think it's not the right track to send large data between activities directly or use singleton for that purposes:

    1. You will send every time a large amount of data - it's not good for performance.
    2. You will always keep in memory large amount of objects. That's not good too.

    I think, the best way - is to use database and ORM for that.

    So you can just send query to another activity and use CursorAdapter for list rendering. In this case you could show a huge amount of data, instantly "send" data between activities in two ways.