2

I am building a mobile app to allow for real time messaging, befriending users, creating groups to both chat and share images with, as well as creating events where users can invite one another.

I have chosen to use Firebase as the online back-end. But, given Firebase uses a NoSQL data model, while Android SQLite uses SQL, when saving data offline in Android what is the conventional way to handle this? Is there a simple way to convert or simply save from NoSQL to SQL, or do I need to build a converter?

(This is especially important for the events, as once created, they must be scheduled in the AlamManager, giving users alerts upon event time)

Community
  • 1
  • 1
Sauron
  • 6,399
  • 14
  • 71
  • 136
  • 3
    Firebase has built in disk-persistence on Android: https://www.firebase.com/docs/android/guide/offline-capabilities.html#section-enabling-offline-support I'm not sure why you'd want to implement a different mechanism on top of/underneath that. – Frank van Puffelen Feb 18 '16 at 21:27
  • Do you have a special reason to not use Firebase's offline persistence solution? Do you want offline data to be available in POJO format? – Damodar Periwal Feb 19 '16 at 06:29

1 Answers1

0

While you could implement your own solution, truth is, you do not need to build anything from scratch.

There are free Android libraries which could help you. I would recommend you:

SimpleNoSQL

The transition from Firebase to SimpleNoSQL is pretty straight forward, and is mostly the same as if you were using any form of SQL:

1) You get the data from your remote db: you can get this trough a request to your remote server, it doesn't matter what language you are using as long as it can return a response you can catch.

2) You save said data to your local NoSQL db: once you have the information requested, it is up to you what to do with it. You could save it to a TXT file, a SQLite db, NoSQL db, save it to the SharedPreferences, etc.

Hope that helps.

herrmartell
  • 3,057
  • 4
  • 18
  • 27
  • 1
    Reviewing the code for making a query, that is not very straightforward nor easy...it appears very cumbersome to do the simplest things – Sauron Feb 18 '16 at 19:49
  • I find easier to simply work with a SQL library. Compared to the classic SQLite way, they are much, much easier & save you a lot of coding. But then again, if you find SimpleNoSQL hard or not-straightforward to use, you probably will not like those either. – herrmartell Feb 18 '16 at 19:58