Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:52:18+00:00 2026-06-14T16:52:18+00:00

I have some things in my Android application that need to update once per

  • 0

I have some things in my Android application that need to update once per day.

It’s pretty simple I think, but I have no idea in what format I need to format the date and time (if time is needed) and how to check if an update has been done today (where today is between 00:01am and 23:59pm in the user’s local time). The update should not be done if it was already done for today.

Here’s what I DO know how to do:

  • Save the last update date in SharedPreferences (but how do I get a
    string of it, I do not know)
  • Get things from SharedPreferences (but I
    don’t know how to compare dates in string format)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:52:19+00:00Added an answer on June 14, 2026 at 4:52 pm

    It is irrelevant what format you choose. It is just matter of recalculations.

    I’d suggest using milliseconds since epoch, as all system calls use it, so it would be easier for you to use the same.

    As 1000 millis is 1 second it’s easy to figure out that 1000*60*60*24 equals to one day (24hrs). So, if storedMillis is bigger than NOW - 1000*60*60*24, (and NOW is i.e. System.currentTimeMillis()), then it is too early to do the check. If storedMillis is smaller, then save your NOW timestamp and do the check:

    long now = System.currentTimeMillis();
    long diffMillis = now - lastCheckedMillis;
    if( diffMillis >= (3600000  * 24) ) {
      // store now (i.e. in shared prefs)
    
      // do the check
    } else {
       // too early
    }
    

    EDIT

    I am interested in doing it when the app is first opened for the
    current day, even if the last update was done 10 minutes ago.

    It’s just the matter how to get the proper millis to compare against. Replace long now = System.currentTimeMillis(); from above code with following code block:

    Calendar cal = Calendar.getInstance();
    cal.clear(Calendar.HOUR);
    cal.clear(Calendar.HOUR_OF_DAY);
    cal.clear(Calendar.MINUTE);
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MILLISECOND);
    
    long now = cal.getTimeInMillis();
    

    which shall do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this application that need to do some things in protected paths (like
I have some things in my app that I need to store, in order
i am building an android application but i have some questions about the memory
I have created in android an application that downloads via FTP connection some content
I have problem with my Android application. I need an application that will send
I have searched through Google, SO and Android developers but I need some further
I have code in global.asax that sets some things in cache with CacheItemRemovedCallback. When
I have a ImageView and draw some things on that view. Now I want
I have some C# class libraries, that were designed without taking into account things
I have an Android application with a main activity that is the tabhost. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.