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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:21:33+00:00 2026-05-25T00:21:33+00:00

When my activity is ran for the first time it downloads some url strings

  • 0

When my activity is ran for the first time it downloads some url strings and sets them to.

a String list…

public   String [] myRemoteImages = {imageUrl,imageUrl2,imageUrl3,imageUrl4};

the imageUrl’s inside are 4 url’s that are downloaded and set to the variables..

When the activity is closed or destroyed, how can i save these url’s to their variables so they wont be erased when the activity is destroyed?

Could i possible save it in a bundle and then onRestoreInstanceState pull them out?

  • 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-25T00:21:34+00:00Added an answer on May 25, 2026 at 12:21 am

    If you want to save these strings during activity re-creation use the following method.

    public String [] myRemoteImages = /* ... */;
    private static final String KEY_URLS = "urls";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (savedInstanceState != null) {
            myRemoteImages = savedInstanceState.getStringArray(KEY_URLS);
        }
     }
    
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putStringArray(KEY_URLS, myRemoteImages);
    }
    

    If you want to keep these string alive when your application is closed by user you’d better use SharedPreferences.

    onRestoreInstanceState() is called when the activity is restored. It means that this activity is recreating after configuration change or after a process containing this activity was killed and re-launched. So if you want to save a state before your app closes, use onPause()/onResume() methods to save and restore it.

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

Sidebar

Related Questions

The main activity includes some variables with set values. I created a sub-activity with
i keep getting NullPointerException on this line: SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this); i ran some
A long time ago I ran into a website (I unfortunately lost the address,
My activity's background is showing up with some horizontal lines on both emulator and
I have an activity that loads some content using an AsyncTask. If the content
Just getting started with WF4. Ran into a problem with passing some text from
The activity monitor in sql2k8 allows us to see the most expensive queries. Ok,
An Activity occurs at a location on a specific date, but each activity may
My activity needs to communicate with a java server located on my dev machine.
I have an activity that has a TabHost containing a set of TabSpecs each

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.