I have an app that gives to the user all chapters of a book. I want to make each chapter downloadable if the user wants to download it, with a button. I would like to know how to do this. I'm using Firebase Realtime to get these chapters from an online DB. Should I save the downloaded chapters in a local database on phone or have another way? I'm already using dbref.keepSynced(true) and FirebaseDatabase.getInstance().setPersistenceEnabled(true). But I want to save in cache just the chapters name, not the text of the chapter.
I want to make each chapter downloadable if the user wants to download it, with a button.
You can indeed create a local database like Room, but I don't think that's really necessary since the Realtime Database already provides an offline persistence mechanism.
Should I save the downloaded chapters in a local database on phone or have another way?
This is what the Firebase Android SDK already does.
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.
... or can I acess it remotely? If yes, where/how?
To illustrate my question with an example:
If I want to implement a login function and an user creates an account: will his login information only be stored on his phone? (So he can only login on his phone on nowhere else?) Or is it stored somewhere else?
I'm quite confused at the moment and wasn't able to find good ressources zu answer my question (maybe someone knows a good tutorial?)
Thank you in advance for your answers!
There are mainly 3 ways to store data in android:
With the shared preferences, you can save data locally. Its limit is that when you close your app the data are deleted.
With SQLite the limit of the shared preferences is overcome. You can save data into a binary file stored locally in your phone. For use it you have to write some specific java code and inside it write in SQL sintax. It is used for example to keep the highest score in single player game, or simply to let the app remember description, text, user inputs.
With Firebase you can save data in a not local way, data are stored in a server. You can use it for example for develop a social, a game that need to share data with more users, when you have a multiuser application.
This is a data file storage overview, it could be useful too.
For login data it's better to use share preference instead of SQLite. If you use SQLite or Room or share preference, data are saved locally and you can't access them remotely.
I wanted to start my project for a bilingual terminology app and for the noun terms I wanted to store images in the sqlite database and display whenever the user clicks the term. I know how to add the images in database using the app but I don't have any idea how to store it directly in database using SqliteStudio.users do not have the option to store image in database but just to retrieve to when the option is clicked.
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.
Is there a way of count the number of SQLite Databases in my app without the need of inform their names? I need to make the following thest:
If there is one or more Databases in the app, I want to direct the user to the login screen, if not, send him to a sync screen where he informs some personal data and the database is downloaded from my webservice.
Ps: The app is a remote version of a web based system, and unfortanatly it needs to have one database per user and it's name isn't the same for everyone.
After the answers I've decided to create a standard database saving the user ID and name, so if it's empty the app opens the login screen, if not it opens the sync screen.