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 9183441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:48:12+00:00 2026-06-17T18:48:12+00:00

I got a property, persisted in shared prferences. there are 2 places refer to

  • 0

I got a property, persisted in shared prferences.

there are 2 places refer to it in entire code:

firstRunTimestamp = wmbPreference.getLong(ApplicationData.ParametersInternals.FIRST_RUN_DATE, 0);

editor.putLong(ApplicationData.ParametersInternals.FIRST_RUN_DATE, new Date().getTime());

In my logs I found this exception

"java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long at android.app.SharedPreferencesImpl.getLong("

And the stack indicates this code is inside the method that access this property,
Can anyone explaing how it is even possible?

  • 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-17T18:48:13+00:00Added an answer on June 17, 2026 at 6:48 pm

    SharedPreference stores all the data in the form of key value pairs. Both key and values being string. (This is not true if you explicitly store values to the SharedPreference as Long. Check my reply to below.)

    You need to parse the Long value from your string as

    firstRunTimestamp = Long.parseLong(wmbPreference.getString(ApplicationData.ParametersInternals.FIRST_RUN_DATE, "0")); //Notice here, the default value is also made a string. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got below code from http://msdn.microsoft.com/en-us/library/dd584174(office.11).aspx for adding custom property in webpart tool pane.
If I've got Foo with a property of type Bar. Both are persisted in
I got a scenario like this Class Parent { Property A; } Class A
I got a business object bounds to a form (each property is bound to
I've got a problem converting an object property to string while using reflection... string
I got a strange exception when trying to find out if a property in
I've got a model that has a nested property, which has more nested properties.
I've got some Columns in a DataGridView that have their Binding property set to
I've got a winform with a BindingSource that has an int property named Opacity
Say that you've got IList or List as a property. How do you work

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.