jirawatee / FirebaseStorage-Android

Firebase Storage code guideline for Android developers
46 stars 23 forks source link

how to use local sqlite database along with firebase database android #1

Open shruity opened 8 years ago

shruity commented 8 years ago

In my app I have SQLite database. I want to introduce sync between devices of my users. I want to combine my local SQLite db with cloud Firebase db.

I want my sqlite database to be stored on firebase database when the users are logged in otherwise let it store offline. Any changes to the local database should be reflected on firebase database when logged in. Also if user deletes the local database he/she can retrieve it from firebase database. I just want to use firebase for the synchronization between local database and firebase database.

But i have no clue how to do it. Can anyone please help me with this? My app is in android with java as a backend.

jirawatee commented 8 years ago

Firebase Realtime Database is able to store datas in the local by firebaseDatabase.setPersistenceEnabled(true); and there is functions to handle an offline mode as well.

For example if connection is offline while you chat, Firebase Realtime Database will store datas what you chat in local till connection back to online Firebase will sync datas in local to Firebase server automatically.

For me I will store datas in SQLite or Realm if I want to use a search function like "%LIKE%" Hope my content above will help you.

shruity commented 8 years ago

I got a little bit understanding only. Basically I have a fitness app and I save the exercise time, their ratios in sqlite and show them in as a report. I want to sync my sqlite data to firebase on button click and the data to be retrieved from firebase and show in the same form as shown by sqlite. I want to use sqlite as a backend but want to provide the user an option so that he can sync the data with firebase if he wants and only when he is logged in. I am facing difficulty to understand how could it be done. I would be grateful if anyone can help me.

waoowa827 commented 7 years ago

shruity did you fix your problem?If yes then please guide me how you did that.

shruity commented 7 years ago

You can go through the link below: https://www.androidhive.info/2016/10/android-working-with-firebase-realtime-database/

jcarlos79t commented 7 years ago

to take into account that firebase only stores 10MB offline

sasanksrivatsav commented 7 years ago

shruity are you using sqlite for local storage ?

waoowa827 commented 7 years ago

yes

On Thu, Nov 9, 2017 at 1:58 PM, sasanksrivatsav notifications@github.com wrote:

shruity are you using sqlite for local storage ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jirawatee/FirebaseStorage-Android/issues/1#issuecomment-343081866, or mute the thread https://github.com/notifications/unsubscribe-auth/AZMYaS6Y9kysVFEDP7I3L96VYVeUY-ttks5s0refgaJpZM4Jqpvn .

gopib23 commented 6 years ago

how you sync firestore data with local sqlite data, can you anyone help me

RowlandOti commented 6 years ago

Hi, @gopib23 Firestore database already uses SQLite for offline support, hence using a separate SQLIte is not only an overkill but quite unnecessary.

mynormeza commented 5 years ago

@RowlandOti ,Hi, can you provide a Link from where you got that information?

HamzaMinhaj2019 commented 5 years ago

Which information ?

On 28-Dec-2018 9:20 pm, "mynormeza" notifications@github.com wrote:

@RowlandOti https://github.com/RowlandOti ,Hi, can you provide a Link from where you got that information?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jirawatee/FirebaseStorage-Android/issues/1#issuecomment-450385425, or mute the thread https://github.com/notifications/unsubscribe-auth/Aeg2g7sBJu09cZYBBTx22kh6HeXgLtiZks5u9kTGgaJpZM4Jqpvn .

mynormeza commented 5 years ago

Information which proves that Firestore uses SQLite for its offline support.

Hi, @gopib23 Firestore database already uses SQLite for offline support, hence using a separate SQLIte is not only an overkill but quite unnecessary.

RowlandOti commented 5 years ago

Hi, @mynormeza , you can even check the following error: - https://stackoverflow.com/questions/47746100/how-reliable-is-firestore-as-an-offline-persistence-mechanism

The only reason, I would see you having a different cache layer with your own SQLite implementation is when you want to cushion yourself against vendor lockdown. Firestore won't give you access to the local SQLite, so it is better to have one you can access.

cgthayer commented 5 years ago

Related Question: I'm wondering if there's a way I can use SQLite on my backend (not on phone) to do relational stuff, but have Firebase / Firestore keep each Table as a Collection? This way I can have relational SQL queries and reports in my backend, but my Android App has up-to-date access to the data as plain raw collections (tables)?

DavidInnocent commented 5 years ago

Am having the same problem.

meghana-khr commented 4 years ago

please help me to save Realtime data in a local storage for offline support Thanks in advance ..waiting for your reply

ErR0rpj commented 3 years ago

Firebase Realtime Database is able to store datas in the local by firebaseDatabase.setPersistenceEnabled(true); and there is functions to handle an offline mode as well.

For example if connection is offline while you chat, Firebase Realtime Database will store datas what you chat in local till connection back to online Firebase will sync datas in local to Firebase server automatically.

For me I will store datas in SQLite or Realm if I want to use a search function like "%LIKE%" Hope my content above will help you.

I was using this solution for quite sometime for my app. But now users do a lot a reads and my firestore free limit is getting exhausted daily. So, i want to have SQLite in my app synced with firestore just for changes and not reading all the data to reduce the reads. Is there a way to do this?

rybandrei2014 commented 1 year ago

@ErR0rpj hi have you found the solution?