When to store Firebase chat message into SQLite - android

I know many chat app(one to one) using SQLite locally to store messages
and I also think to store every message in Firestore databases
is not good.
but here I confused
When two users are online and seeing chat at the same time
it is not a problem
but one sent message and another one came after it would be a problem
I mean how to store them into SQLite?
another one does not have a message to store because when he came back
it`s nothing
thank you for advice

Well I don't see any problem saving all messages on database if you want offline integration, just code a way to delete all your messages whenever the user wants. If you're afraid of size growth of your app, I suggest you to make your own test, take a clean install and save 100 messages on your database and see how much bytes the data storage increasead.
You should care more about loading your messages, you'll need to develop pagination aproach to load your data and you'll be fine

Related

What is the best way to store app data and load it in app?

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.

Android, when to load user data and where to store it

I recently started working on Android apps, and im having a hard time deciding what approach i should use for this issue. For simplicity sake, lets assume we are making an app identical to Instagram. I have a back end server that has all the user data. The user logs in, and is on the main activity and now :
Should i fetch all the user data, all his photos, all his info now (directly after he logs in), and store it in somewhere, so when he visits the profile activity all his info is already on the device, or should i download all his photos and info when he clicks on profile? If its the first option, where should i store his data(photos,ext) after i download it? SQLite ?
Obviously this questions extends to other stuff as well, like should i download all his messages when he logs in, or should i download all his messages when he clicks on the messaging activity. Thank you!
EDIT: I am also new to Stack Overflow, and have been getting some down votes, if you are planning to down vote, could you please comment your reason as well, so i can get better.
This question is a bit too broad to answer properly. In my personal opinion this will depend completely on what you are trying to build. For example, ideally you would be combining local database and remote database for the best user experience. As we know, items locally are faster to load, therefore it will be a better user experience. However you can't store everything locally as you mentioned with messages. Instead in this use-case you would only save the last 10-20 messages. Sql-lite with Room as a wrapper is a great combination for a local database.
Android Basics
Room database

Best way to upload /sync app/game data to server. (Android Studio)

i have created a android app with sqllite database/android studio.its like a game.i want to upload users high score details to somewhere so users can see who is the best in a app highscore table.
i already created game and sql datase.
i dont know any method to upload data.
am i want to create a server?
can i use google drive or onedrive or something?
if i can upload to data to onedrive or something,
and if i know a method to connect to it,
i can calculate other users data and make the highscore table.
thanks please help.
For this task you would need to create a server with a database holding info for all of the registered players, or if you only want to keep track of the HighScores, simply keep the top ten results. Then you would have to sync the SQLite on the device with the database on the server on every app start or exit. On start you would pull /GET/ data from the server to update your local DB, and on exit you would POST your local results to the server. Then you could chose how to implement the server whether to track all data or just check if some of the results are good enough to be in top10 and write only them.
This is a fairly trivial task.
I recommend you read about JSON in Android, HttpUrlConnection and get familiar with the basics of HTTP.
You could easily figure out the "server-side" of this task simply by rolling over few videos in the web. Hope I've helped.

How does Twitter App in Android cache/store tweets in the listview?

In Twitter Android App, Once the listview is populated with tweets/items downloaded from server, it never again talks to server to fetch them again. Even if you kill the app and start it again, it still retrieves the same old data.How does twitter store this much of data. Is it using database, storing all downloaded data in a file or caching.
In my app , i have a similar requirement.For now i store the downloaded listview data in a file and then read it whenever the app is started afresh.Is there a better approach or a followed patter for this.
Thank You.
There are three ways to save/persist data on clientside. These being:
SharedPreferences (not ideal with requirements)
File I/O
SQLLite database
As far as I know there isn't a big difference is performance between file-I/O and SQLLite. But SQLLite has a lot of other advantages.
You can query the database, this is more easy then writing it yourself with file-I/O
Manipulation of data is for more easy and less painful (delete/update records etc)
Supports relations between data!
Bottom line, go for SQLLite, it seems more work to setup but you will benefit from this in the future.

Syncing online database data with local sqlite database android

I couldn't really find information on this particular problem anywhere even though I know there is a lot of questions and documentation on sqlite so sorry if this is a duplicate.
Anyways, I'm developing an app which logs a user in and performs actions on a mysql database on my website via php scripts. But so that the user doesn't have to wait for a web response for every button they press/every activity launch, I have a sqlite database attached to the app which stores the live information as the app is being used (It uses GPS tracking so this data is stored as well as other things).
I suppose my question is, how much should I store locally to be uploaded later? Should I try and do everything locally after initially logging the user in and just uploading/syncing the data in the user's profile onPause() or something and make use of the lifecycle? Or should I do the opposite and try and do everything live online and get rid of the local sqlite database altogether?
Just wondering if anyone has had experience with this kind of situation and what conclusions they came to.
Thanks for your time,
Infinitifizz
There are some sqlite3-rdiff tools for syncing SQLite databases at mobigroup

Categories

Resources