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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:25:59+00:00 2026-06-15T22:25:59+00:00

I switched from a singleton to an application object to store application data because

  • 0

I switched from a singleton to an application object to store application data because as I understood it, there was a much better chance of my cached data surviving in an application object, than in a regular singleton.

I am still having issues however. If I switch to several other apps, and come back to my app, the call to load my event after i’ve loaded getApplication() is throwing an null pointer exception.

What I find even more bizarre, is that the bundle from my original intent, is still active and has survived the application switching.

How can I keep data, which doesn’t necessarily need to be persisted in a permanent way (if the entire application were killed, and reloaded, it would just pull it down from the webservice and start fresh, this is why I thought switching to an application object would be ok )

  • 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-15T22:26:00+00:00Added an answer on June 15, 2026 at 10:26 pm

    Are you looking to persist data relating to when your application is put into the background by the user, and then brought back?

    Perhaps overriding the methods onSaveInstanceState and onRestoreInstanceState, and storing and recovering from a bundle is what you are looking for.

    http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState(android.os.Bundle)

    http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState(android.os.Bundle)

    You may then want to define a Parcelable interface

    http://developer.android.com/reference/android/os/Parcelable.html

    on the classes you wish to store.

    Alternatively You may also use the shared preferences api.

    http://developer.android.com/reference/android/content/Context.html#getSharedPreferences(java.lang.String, int)

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

Sidebar

Related Questions

I've recently switched from storing session data in a cookie to storing it in
I have just switched from VB.Net to C# and am writing a windows application.
I've switched from a Website Project to a WAP (Web Application project). The WDP
We have switched from sqlite to FireBird embedded server, because FB seems to support
I'm currently using a singleton as a data store for my app. I essentially
I've switched from LINQ to SQL to ADO.NET (with MSSQL) because of a problem
I recently switched from Vim to MacVim because it has Ruby support, however, the
I've recently switched from log4j to logback and am wondering if there is an
I switched from Windows 7 (32 bit) to Windows 7 (64 bit) because i
So I just switched from some network solutions hosting running some php files that

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.