views:

60

answers:

1

I would like to pass a considerable sized amount of data (~1500 bytes) between two applications in Android where performance and resource allocation is a priority. The data is basically key-value pairs. The rate at which it needs to be passed from one application to another can vary from a trickle to ~50 packets within a second. I figure I can either:

  1. Wrap all the data inside a bundle, and pass the bundle via an Intent from one application to another. I worry about the performance implications of allocating and de-allocating all that memory to store the bundles.

  2. Write all the data to a SQLite database and provide it to the other application via a content provider. Here I worry about the performance implications of writing all that data to disk, and then having to read it back from disk when it is requested.

So, which is the lesser of two evils?

+1  A: 

Consider using a service connection. You pay some overhead in setting up the initial connection, but after that, you can use an RPC-like interface to make method calls (passing Parcelable structures in either direction) with very little overhead (well under a millisecond). See this page for details.

Yuliy