42
Views
6
Comments
Solved
Share local storage over multiple apps

Hi all,

I'm working on several Android apps for the operations in a distribution center. Those apps are retrieving data from Java API's among which binaries for product images. The apps should keep working on connection loss, therefore we store data locally. ProductImage binaries are not (yet) stored locally but called asynchronously when needed. A placeholder image is shown when the call fails (no connection / no image found / etc.).

We already added caching in the Server Action that calls the GetProductImage API, but to prevent a lot of server requests and to make images available when the device is offline, i'm trying to find the best practice to build a caching mechanism to store the binaries locally (with a maximum age) on the device. 

The challenge i still face is in the availability of that local data. I think currently local entities are only available to one app and the same entity cannot be used by multiple apps? Does someone know a way to make this possible?


Edit:

Just found this link. The idea could maybe something like this:

source: https://developer.android.com/guide/topics/providers/content-providers.html 


Thanks in advance!


Kind regards,

Jobbe

Rank: #70
Solution

Hi Jobbe,


I have tested this situation recently creating two applications which reference the same local storage entity and the result is two tables so the data is not shared between multiple applications.

Thinking about your scenario, you can reduce the amount of data going between server and client if you have a table with the following fields:

  • Product
  • User
  • Device
  • Picture URI in the device

If you have such a table, once the product is saved on Application A, you can save on the server the location of the image on that device. In this way, when you synchronize on the other apps, you won't be syncing binaries anymore but just a URI (fetching by device id) which will make your scenario much more performant. For saving files in phone and getting the URI, you can use the verified File plugin.


I hope it helps.


Cheers,

João

Rank: #82216

We already added caching in the Server Action that calls the GetProductImage API, but to prevent a lot of server requests and to make images available when the device is offline, i'm trying to find the best practice to build a caching mechanism to store the binaries locally (with a maximum age) on the device. 


Rank: #683

Hey João,

In the meantime I worked on a generic way to make "locally cached items" as a concept available for all apps on the device. Thanks for your help, I used your solution to make that possible.

I thought it could be useful for more OutSystems developers so uploaded the component in the Forge. 

https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=9617


Would really like to hear what do you (and others) think about it!

Rank: #70

Hi Jobbe,


I am glad it worked and it is great you created a component for that, hadn't thought about that.

It looks pretty solid, kudos!


Cheers,

João