• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Advice how to structure the app database structure

Hi guys,

this is my first post here on AndroidForums. I have been working with Android as a programmer since at least 3 months.
I have managed to work (sometime by following an online course) with database, API to retrieve Json file from internet, Firebase (uploading of pictures, authentication, real time database) and other stuff.

I wouldn't consider myself an expert and that is why I'm here asking your help.

I'm thinking about developing an app which will contain a decent amount of data stored in the local database (SQLite) and while browsing through this data I would like to give the user the possibility to have access to extra content that I will personally upload to a Firebase database.
To simplify the example let's imagine that the app will have once you download from the Play Store, 1000 SHOPS so even without internet you can browse through those stores.
I will be responsible to add NEWS that those stores will publish and if a user is connected to the internet can see in the page dedicated to a specific store its NEWS that I've inserted in the Firebase db.

I'm not sure if this is the best way to achieve what I want to achieve.

Any advice?
 
So assuming that I will follow this plan, I have a couple of points to make more clear

1) what is the best way to populate the "original" SQLite database before publishing the APP? Following the simple example mentioned above if I have 1000 shops with a bit of info to add how can I add that data to the SQLite db?

2) Assuming that the number of shops will increase (or decrease) or have some data modified, do you think is a good option to store the SHOPS even in the Firebase db? By doing so the idea would be to have the app offline data always update.

3) [not properly related to Android programming] what would be the best option to have a private control panel to populate the firebase db? I would exclude automatically the CONSOLE of Firebase not quite user friendly when it comes to add big amount of data
 
1) You should have a DB helper class. This includes the method onCreate() which is called when the database gets created for the first time. There's also a corresponding onUpgrade() method, which gets called when your application updates itself

https://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html

Btw if you're feeling adventurous, consider using Android's persistence library, called "Room". However the traditional way of interacting with database in an Android app, is to use the DB helper class, as described above.
Here's the documentation for Room:

https://developer.android.com/topic/libraries/architecture/room.html


2) Yes I do think a centrally held database, containing more dynamic data is a good architectural model. Your app can periodically refresh its local data with the centrally held 'fresh' data. You could nag the user to update the local data after a certain period of time being offline.


3) Must admit I'm not that familiar with the tools available to Firebase, because I've not used it in anger yet. I'd be in the same position as you really, having to research the options.
 
Back
Top Bottom