Ahmed Sabry
Ahmed Sabry

Reputation: 494

resume activity from where it stopped without lose data

Hi i've problem with activities because i'm Newbie in Android i have two activities : when the first activity finishes, the second begins and the second activity are change in it's content elemnts


( This in the first "default" Activity )

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();

        final Context context = this;
        AppPrefs appPrefs = new AppPrefs(context);
        String Last_Activity = appPrefs.getValue("Last_Activity");
         if(Last_Activity == "listV"){
             finish();
             Intent i = new Intent(this, NewClas.class);
             startActivity(i);



         }
}

when app is in background then i open it: every elements that had changed became as what it was ,

i mean that All changes returned as before

What I want is resume activity and appear it's changes that it was making when app was in background.

Sorry for my English i hope someone helps me Thanks a Lot ..

Upvotes: 0

Views: 179

Answers (2)

Nermeen
Nermeen

Reputation: 15973

You can use onSaveInstanceState() to save any values you want in a bundle and then restoring them in onRestoreInstanceState().

Upvotes: 1

user370305
user370305

Reputation: 109237

Ahh.. Your If condition never become true,

It should be like,

 if(Last_Activity.equals("listV")){ ... }

Upvotes: 2

Related Questions