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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:40:55+00:00 2026-05-26T11:40:55+00:00

Im building my first android game, my problem is: When I exit from the

  • 0

Im building my first android game, my problem is:

When I exit from the app with my phone’s “back\exit” button, my app is closing and all the information I need is nicely saved to a preference file:

 @Override
 protected void onPause() 
 {

 super.onPause();

 // My pref file
 SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, 0);
 SharedPreferences.Editor editor = preferences.edit();

 // Put the values to the pref file
 editor.putInt("CsereHolTart", CsereHolTart);
 editor.putInt("melyikAct", melyikAct);
 editor.putInt("Silver", Silver);
 editor.putInt("Strength", Strength);
 editor.putInt("Intelligence", Intelligence);
 editor.putInt("Dexterity", Dexterity);
 editor.putInt("Speed", Speed);
 editor.putInt("Vitality", Vitality);
 editor.putInt("Morale", Morale);
 editor.putInt("cHp", cHp);
 editor.putInt("cMp", cMp);

 editor.putInt("isGame", 1);



 // Commit to storage
 editor.commit();


  }

See? I simply use the onPause() method to put all the things I need to a preference file actually to this:

public static final String PREF_FILE_NAME = "PrefFile";

When I open the app, all the saved data is well read, and my app continues from the right pont with the valid values I saved then loaded.

THIS IS GOOD, BUT:

When I close my applicaton with my phone’s task manager, so i manually do a “force close”, it seems onPause() is just not running, or something else I dont know. So the matter is when I close my app with task manager, all the loadings are fails, it seems all the saved data is deleted. Becuse every preference is loaded to default in that way.

Can anybody tell me what should I do to solve this task manager’s force close problem?
I want to save and load everytime the user exit from the app or opens the app.

  • 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-05-26T11:40:56+00:00Added an answer on May 26, 2026 at 11:40 am

    When I close my applicaton with my phone’s task manager, so i manually do a “force close”, it seems onPause() is just not running

    If you are in the foreground and kill the process via some sort of task manager, onPause() will not be called. onPause() is only called when some other activity takes over the foreground.

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

Sidebar

Related Questions

I am building my first ASP.Net MVC based app and have a problem accessing
I'm currently developing my first android app, and my first game. I've been developing
I have been slowing learning and building my first android app. I'm VERY new
It is my first time building an android app. Was wondering firstly, if there
I'm building my first android app - something that will display my tweets in
I'm building my first Android program from a book. It kept crashing on an
I'm building an Android app that runs off of a rails server. At first,
I'm currently building my first app for Android. What I'm having trouble with is
I'm building my first Android app and its nearly ready for release. One thing
I am building my first android app, and I am a bit confused with

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.