Deleting firebase data after 'n' days but in reference to server time - java

I want to do similar things like in this post:
How to delete firebase data after "n" days
But the solution given there allows user to delete everything from database by changing the date on his phone.
How to deleting firebase data after 'n' days but not in reference to the time set by the user.
Where can I get "a safe time" which couldn't be changed by the user of app?

Related

How to reset a value after 24 hour passed in android

I want make a kind of a daily login reward.
I have a button named ClaimReward and A user can claim reward one time in a day!. if user claimed the reward then disable the button and if
24 hours passed then again enabled the button.
My try
I stored a today's date in firebase realtime database in millis (long) or timestamp - 1353534920
So, how can I do this in android
You can get this output with this logic.
Store the value you want to reset to the preset value using shared preferences
Store the date-time value from the system using the sharedPrefs.
On App startup check if the local time matches the time in sharedPrefereces.
If it matches -> do nothing
if it does not -> reset
PS: Here shared preferences is just an example you can use room/datastore or anything to perform this check on app startup.

display user according to there last chats in recyclerview

I have created a one to one personal chat application for my college project. As users chat with each other there chats are been stored in Firebase as in the following manner
+ Chats
+currentuser
+Reciverid
+postPushid
+informations
I want to display the users to whom the current user had a conversation according to there the last message means as the new message is been inserted under the current user chat node that users id should show on the top as according to there time of insertion.
Help me out to arrange according to user ids according to there last message time in Firebase.
Just add one more attribute as timestamp and generate it by using the command
long timestamp = System.currentTimeMillis();
save that to firebase when uploading the chat message with a negative sign like
timestamp = -timestamp;
Now in Query variable just add the this
query.orderByChild("timestamp");
this will select the value which is least but the value in positive becomes least in negative and that's how it gets resolved.
I already implemented the same logic. I did other model of chats. I have separate table with users. Separate table with chats where each user see only users he got chat with. And I have separate table for messages where id is the chat. So in this case it is very to manage and it is flexible. You can add/remove fields from each model separately. Want time stamp in messages no problem. Want timestamp in chats no problem. All tables maximum got two levels instead of five you got. So i would recommend think about restructure of db.

How to insert data into database in next row automatically

I am working on access control system with a database as a project. I want to the database to serve as a data log. That is, I am writing a program that writes the login time and logout time to the database and also logout date whenever access is granted to a user. What I am finding difficult is causing the cursor go to the next row whenever a user is inserted into the database(is logged in). Can anyone help me on how to use Java to get this done? I want each user to be inserted into database in separate row so that even if the same user logs in a day after, it goes to the next row not being updated or over written by new data log
Thanks guys, I have figured it out. All I have to do is auto increment the raw number each time data is written into the database. When data is sent to the serial port, it will be read as strings. the string of characters which represents users card number is also available in another separate database table. The read card number is compared with those in that database table. if match is found, Names of the user having the card number will be SELECTED and written to the log table. Each time there is data in the serial port the row number is incremented.

android, Everyone should evaluate each day only once

I'm going to build an app. Until now everything runs very well. Now I have a problem. The app gets its content from a mysql database.A column is called item.I have a ratingbar. The user can rate the item there.Every time the user evaluates an item the value is stored on the database in the respective item line.The values ​​are then added. In other words, when a user evaluates 20 times with 5 stars, the value adds up to 100 and so on.
I want to limit this. I will that the user can evaluate each day only once an item. I will it without a registration mask for the user. How can I solve this problem?
I know that i can identifier the WIFI MAC Adreess and other Unique Identifiers, but how can i solve this with them?
I can not use sqlite database, because the items should update with the time from the mysql database.
A registration mask should not be excluded. If this process is quite possible with them, then I supplement it with it.
I am looking forward to every comment
every computer has a machine ID, you will hash that and encrypt that to use as your identifier..most telecomms do not like using MAc addresses as IDs
One option would be to create UUID during every installation and sending this UUID to your server along with every request. In server, you can control very well if user can provide feedback once a day or others based on your requirement. Pls refer this link on how to create UUID.
https://developer.android.com/reference/java/util/UUID.html

In-App Billing V3 - Purchase an Object that expires after 3 months - Android

I must implement in an Android App the purchase of an item that expires after 3 months.
I read on the developer guide that I should use "unmanaged" products, but I also read that in V3 Version of the API this object is handle as a managed product.
The question is the following, after the users buy an unmanaged object how can I manage the expiration?
For example when the period will expire, the user can purchase another time the same product if he want?
Are you using an online database for your app?
If true, I think that the best way to do it is generating the end date when item is purchased and saving it in an online database. Then you have to check if end date is not past regularly in your app (for example every time that user start app,...).
This works for me, but in my case app connects regularly to a online database to work.
Other methods, like save end date in local storage can be easy hacked.

Categories

Resources