161
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

2018-10-29 08-31-03
João Marques
 
MVP
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

2023-07-17 14-07-32
Jobbe Maas

Thanks, sounds like a good idea João! I'm going to try this today and let you know if it worked.

UserImage.jpg
NATYRAF VATYIA

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. 


2023-07-17 14-07-32
Jobbe Maas

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!

2023-07-17 14-07-32
Jobbe Maas

Meanwhile i did several updates to the component already. Right now it doesn't need to do any server synchronization at all. I save the files with a defined encoding pattern in the filename in which i store the metadata. Hence i can loop through the files and read the metadata to get the reference to which itemid it belongs and which date it's cached (so that i can delete it if it's expired).

2018-10-29 08-31-03
João Marques
 
MVP

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.