I am working on an app that will be used offline. What I want to do is that when the app is first started (has to connected to the internet) tables are downloaded to the device so that it can be used offline. All data that is stored when offline will be uploaded once the device is back online.
I have noted that local storage consists of keys and values (no tables). I have surmised that I will have to generate keynames that are akin to the Row-Column format so that I can keep track and then parse appropriately when uploading the data.
For example, if I have a Vehicle table that has columns registration, make, model I would have keys like Reg_1, Make_1, Model_1 for the first record, etc.
I believe that this will suit my purpose but would be grateful if anyone could let me know if there is a more efficient way.
What I am unsure about is how to test if the device is connected to the internet so that the upload can be processed.
The approach you suggested for storing data in a key-value format might not be the most efficient. Generating keys and managing them can complicate the app’s logic and negatively affect performance. For local data storage, it’s better to use databases like Hive or SQLite (SQLite is built into Android). These solutions provide more flexibility and allow efficient management of tables.
For checking internet connectivity, you can use the standard Android library ConnectivityManager, which helps monitor network status and trigger data uploads when the device is back online.
Unfortunately, we don’t have a tutorial on using SQLite, as for ConnectivityManager you can add an external library in Ui-builder - Settings. And try to integrate it into your application using custom components.