This question already has answers here:
Determine if Android app is being used for the first time
(15 answers)
Closed 2 years ago.
I want user to input some information on the first time they start the app so that those information can be used from that on. What are the possible ways to do this?
if you are looking at storing large or complicated data you can save it with room database. if you need to store simple data you can use shared preferences.
you can save a variable in shared preferences such as isFirstTimeUser=true or false then you can check this variable when the app starts. If it is the users first time to use the app present them with ui to create the fields you require. If not then proceed to fetch the details
Related
This question already has answers here:
Can Firestore update multiple documents matching a condition, using one query?
(8 answers)
Closed 2 years ago.
I have created a chat app. In the app there is a collection named Chat and in it there are documents. Each document is a message that was sent and it contains fields such as Message, SentTime, IsButton.
Once something happens in the app (someone clicks a button), I had like to change in all of my documents at that chat the value of IsButton from False to True.
The data looks as follows:
Is there a way to change all of the Field values in one hit instead of using a loop?
I saw there is something called Batch however I'm not sure if it is limited to a maximum 500 updates.
Thank you
The two approaches you've found are pretty much the way to update a bunch of document.
You can:
either update each document individually, which is not nearly as slow as you may think.
or you can update the documents in one of more batches.
Having to update many documents with the same value may be a sign that you should reconsider your data structure. For example, maybe you can store the IsButton in a single, separate document that all clients then read/listen to.
This question already has an answer here:
Firestore and Auto Increment Ids
(1 answer)
Closed 3 years ago.
I use Google Firestore as database in my project. It creates random generated id's for document names. I understood it's made with an purpose and I must use timestamp as a field in my document to order them by time they created.
On the other hand I also need a field that increase sequentially every time a new object added to the database. And I need to show customers this field because it will contain Order Id.
What is the best practice and how to create a field sequentially increased every time a new object created. How to manually increase new item realted field?
Sorry if it is an easy question, I am just lost. Any help is appreciated.
Seeing that you want a sequential order ID, you can probably maintain a document that stores a counter of the latest order ID.
Every time you want to add a new document, increment the order ID and use it to store it in the new document key or data.
As of now it is not possible to do the increment and at the same time read the latest value in a single operation. You would want to do it in a Firestore Transaction as explained in the answer of another question here. I suggest you read the question and the other answers in that thread as they are useful.
This question already has answers here:
Google Firestore - How to get several documents by multiple ids in one round-trip?
(17 answers)
Closed 4 years ago.
I have below FireStore data
And I have a list specialUsers which is defined as
val specialUsers = arrayOf("stark#gmail.com", "lannester#gmail.com")
So I want to get collections which are in the specialUsers, something like
collection("users").whereIn(specialUsers)
But, couldn't find any documentation related to this. How can I perform above intention in Firestore?
As he says here in 6:19
There is still no way for the database to automatically grab specific user name and profile for each review as I requesting them. I would need to make separate database request for every single review I get to fetch this information and that's bad. so If we wont to automatically include information about who rote a particular review we will need to copy sample of the user profile to the particular review and this is the way (to brake data Normalization) specifically in could FireStore.
This question already has answers here:
How to disable the Clear Data button in Application info of Manage application
(4 answers)
Closed 4 years ago.
I am creating an android application which i have store some data in to store preferences,Actually i want to prevent that for further work.
Now what happen user can easily delete that data from app setting.
Is there any way to disable or hide that button from app setting?
You can create a SQLite database file in the external storage so it will not be deleted when the user clears cache or even delete App Data. But you can not prevent any of these to be deleted. User has full control of what can be on the device and what not.
Edit
As #NileshRathod mentioned in the comments below, you can redirect a user to an Activity to manage what could be deleted and what not simply by adding the following in your Android Manifest:
<!--Prevent user from deleting App Preferences-->
<application ... android:manageSpaceActivity=".MyManageSpaceActivity">
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to use getSharedPreferences in android
I am new Android Developer. I have a query regarding Shared Preference.
How long data will be persisted in 'SharedPreference' of Android App?
My requirement is to persist data for a a particular user until he log-off from the app. If same user or new user logs-in from same or new device, he/ she should have no content stored in Shared Preference from earlier session.
Please guide me to develop this. Thanks
SharedPreferences will persist data until you clear/overwrite the data by yourself or until the user uninstalls the app or you clear app's cache.
With respect to your question, when the user logs off from the app you can perform SharedPreferences.Editor.clear() followed by a commit() to remove all saved data of the current user from shared preference.
More info. here: SharedPreferences.Editor clear ()
The Data which you saved in SharedPreference will store until you removed it by programmatically (changing the preference value to null).. or until you clear the history of the app or until uninstall the app ...