Time limits on use

Put your problem here if it does not fit any of the other categories.

Time limits on use

Postby ef em el » Thu Apr 14, 2011 6:34 am

I realize this is a pretty noobish question, how would you go about saving and comparing time between using functions in your app? For instance, I dont want them to be able to post to facebook or submit feedback more than once every 24 hours. I'm assuming i'd save the previous time in sharedPref or something, then compare to the new time to see if 24 hours have passed? If so do the function, set new sharedPref variable for the time to current time etc.

Could someone please show me this? Struggling.
ef em el
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Dec 22, 2010 9:16 am

Top

Re: Time limits on use

Postby imbroken » Thu Apr 14, 2011 9:21 am

You could store the last time you posted with System.currentTimeMillis() and then when you try to post again, get the current time with System.current..., subtract the values and then use TimeUnit class to see if this value elapsed 24 hours.
imbroken
Senior Developer
Senior Developer
 
Posts: 131
Joined: Thu Jan 06, 2011 6:57 pm
Location: Germnay

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 23 guests