I am building my first app with react native.
I am, for now, storing locally with AsyncStorage the user data.
This app is going to make users interact with each other, I am looking at realm.io but for my understanding all the mobile apps save the data locally then sync it to a database.
I am not sure if this is the way and I am doing correct. Basically what I want to do is :
Open the app, load the user data from AsyncStorage
Call the database (from a server) download other users data
Store user and users data in to the state of the app (I use redux)
Sync with the live database at each interaction.
Is this the correct way? For example if is a chat and I want to store the data for both users in to the database, how do I do?
So to recap, how do I store the app data for all users in a live database that is on a server?
What you're looking for is redux-persist https://github.com/rt2zz/redux-persist
What redux persist does is handle all the local storage things on its own any time it changes. So when you reopen the app everything that you want is there. You handle the database loading as you would normally and send it to your redux store and replace the old data.
Persist also has a black and white list for some of the things that you may or may not want to be saved. If you want to save everything in the store though it does it by default.
If you have important things that you want to be saved, you'll want to move it into the store if you have it in the state, because it does not save state.
Related
I am building an App that has same functionality as WhatsApp. I am using firebase(Online Mode) and Room(Offline Mode).
I want that my code should determine when to fetch the data from firebase and when the user is offline just store and show the data using Room Db and whenever the user goes online update in firebase.
Flow:
If Online:
Check if Database have changes if yes fetch data and store locally in Room.
Check if Room Db is changed if yes update UI. [UI should only get data from Room Db]
If Offline:
Store the data locally and change the UI instantly and whenever the user goes online update firebase.
If this is not the optimised solution in respect of App Performance. Please share your thoughts
You are trying to build whatsapp clone. You have to save datas to sqlite when user is online. And, when you are online then, you have to check the size of that person's information. If size changes it means someone messaged him or happened something to database. Then, you can change sqlite information. I think you are just looking for idea not source code. If you want to know source code. Then, implement your source code where you are having error.
This is just a information question. I'm new to Android app development and currently I'm working on my first app and and it is ready for the release. Now I'm concerned about how to handle heap of users and where to save all their details my app is a service booking app so it needs to save all the order details products details and lots other stuff.
Currently I'm using cloud firestore to load and save all the data of app. But I'm having some issues like without authentication it won't allow users to access some of my data and other. I wonder how large apps save their data and load them perfectly.
I wish someone will help me how can I save all my app data and load them perfectly in app. And suggest me for a best way to manage large user base. And other stuff.
First of all, firestore is good option if you don't have complex backend logic on the database. For simple CRUD operations on data firestore is a good choice but as you said you have a bulk of data then you must go for the Backend database and then connect your database with Rest API. So that all your complex queries will be done on the backend and you can simply consume your API in the app.
If you have lots of data from different users, maybe you should use a central server(DB), something like Postgres or MySQL should work fine.
At the same time, you can also do some sort of caching to accelerate the fetching process, like create a small database locally(you can use Room) to store some user specific data.
I'm a new Android developer and could use some advice on a problem I've come across.
I have an app which is querying data from the Amazon Product API on almost every activity you open. I'm able to get the data, but the activities take forever to load because I'm constantly running API queries.
The app is basically a video game review app. It wouldn't be uncommon for users to load the same data for a game multiple times. I'm thinking that making api calls for the same data over and over again is very inefficient.
My question is in this scenario, should I be saving game data to a local, or even remote (Firebase) database every time data is retrieved from the Amazon API? And then whenever data needs to be retrieved, I check first to see if it's present in the database before making the API call?
If this is correct, where should I be saving the data (shared prefs, SQLlite, internal storage, etc.)? If not, what can I do to make the app pull & display data faster?
When you say that activities take forever to load, I assume that you are not making these calls from within the Activities. And lets answer your questions one by one.
1) Shared Prefs are not a good option. (Try to use Shared prefs only when you have a bunch of things to persist). While in this case if you want to save effort of writing helper classes for database you could serialize the data (Internal Storage). And its preferable to store data locally in my opinion.
2) Do not always request the data.Only update it when the user wants the data to be refreshed (hustle free, user presses a refresh button). Or you could update data after fixed time intervals. This can involve upgrading reviews in background even when the application is not running by starting Service using Alarm Manager. You will have to read about it though.
I am new to Android programming and I want to make an online database with information and pictures. In our case we are making app that stores recipes and their pictures. More recipes and pictures will be added in the future therefore it will use Internet to fetch data.
Question:
What is the best practice to store pictures - both old and new ones that will come in the future? On the database itself or on app? And does that mean if we add new recipes would consumer have to update the app if we store it on the app itself and not on web database?
As per my opinion the best practice would be keeping data and images on server and fetching it on real-time as per user need. As saving all images in application and updating more late on would increase the size of application.
You can create local database and cache for your images in which you can store data and images as user goes on accessing your application section, so that user can re-access those sections again in offline mode, but for new data user has to go online, you can instruct user where he would need internet access. Besides this you also need to specify some checkpoints in your flow where application should sync with cloud and update local data.
I have created Sqlite database in app. when I clear data from settings->applications->manage applications the Sqlite db removed. any suggestions to keep sqlite database as it is.
When you press Clear Data from the Android application manager its supposed to remove everything related to the app such as preferences, databases, caches etc the only thing that gets left is the app so when you re-launch it behaves as if it was just installed.
If you want to allow the user to clear the data but keep the database then there should be an option in the menu that removes the shared preferences but doesn't do anything with the database.
Hope this helps.
Android's SQLite is intented for local app data storage. When you opt to wipe your app's data, this data is wiped (as expected).
If you want to persist DB data, look into external storage (eg. the late Parse.com, or MS's Azure). You'll be making network calls, your local data will still be wiped, and you'll need to have a way to link your app back up with the external data post-local-wipe (eg. logging in) but your external data will survive an app data clear.
The "linking up" part can be mitigated as well depending on your use case, eg. Google Play Games' data services is tied to your Google Play id and will resync after an app wipe.
Why would you want to keep the data when the user wants to clear everything.
It is not suggested you keep the db.
I would suggest you use the sd card to store images/text files with the adequate permission from the user.