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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:19:17+00:00 2026-06-11T15:19:17+00:00

I can I retain ArrayList<HashMap<String, String>> in bundle? I want to display ListView immediately

  • 0

I can I retain ArrayList<HashMap<String, String>> in bundle?

I want to display ListView immediately after rotating the screen.

  • 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-11T15:19:18+00:00Added an answer on June 11, 2026 at 3:19 pm

    You dont have to save it in the Bundle. In fact, that seems like a lot of info to store in a Bundle.

    Since you are just saving a HashMap of String objects, you could make a class to cache it for you or make it a static field in the class.

    Static fields are fine to use as long as they dont contain a reference to the Activity or a View or Drawable. (That can cause memory leaks)

    The simplest way you could do this might just be:

    private static HashMap<String,String> myMap = new HashMap<String,String>();
    

    Because this field is static, it will not be recreated when your activity is recreated. Rather, it will still be there for you to use with the same values.

    More ways to store data:

    (These techniques apply to sharing data over a configuration change also).

    http://developer.android.com/guide/faq/framework.html#3

    How do I pass data between Activities/Services within a single application?

    It depends on the type of data that you want to share:

    Primitive Data Types

    To share primitive data between Activities/Services in an application,
    use Intent.putExtras(). For passing primitive data that needs to
    persist use the Preferences storage mechanism.

    Non-Persistent Objects

    For sharing complex non-persistent user-defined objects for short
    duration, the following approaches are recommended:

    Singleton class

    You can take advantage of the fact that your application components
    run in the same process through the use of a singleton. This is a
    class that is designed to have only one instance. It has a static
    method with a name such as getInstance() that returns the instance;
    the first time this method is called, it creates the global instance.
    Because all callers get the same instance, they can use this as a
    point of interaction. For example activity A may retrieve the instance
    and call setValue(3); later activity B may retrieve the instance and
    call getValue() to retrieve the last set value. A public static
    field/method

    An alternate way to make data accessible across Activities/Services is
    to use public static fields and/or methods. You can access these
    static fields from any other class in your application. To share an
    object, the activity which creates your object sets a static field to
    point to this object and any other activity that wants to use this
    object just accesses this static field.

    A HashMap of WeakReferences to Objects

    You can also use a HashMap of WeakReferences to Objects with Long
    keys. When an activity wants to pass an object to another activity, it
    simply puts the object in the map and sends the key (which is a unique
    Long based on a counter or time stamp) to the recipient activity via
    intent extras. The recipient activity retrieves the object using this
    key.

    Persistent Objects

    Even while an application appears to continue running, the system may
    choose to kill its process and restart it later. If you have data that
    you need to persist from one activity invocation to the next, you need
    to represent that data as state that gets saved by an activity when it
    is informed that it might go away.

    For sharing complex persistent user-defined objects, the following
    approaches are recommended:

    • Application Preferences
    • Files
    • contentProviders
    • SQLite DB

    If the shared data needs to be retained across points where the
    application process can be killed, then place that data in persistent
    storage like Application Preferences, SQLite DB, Files or
    ContentProviders. Please refer to the Data Storage for further details
    on how to use these components.

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

Sidebar

Related Questions

how can i retain focus the popuP window? currently it shows the popup window
Can't the server just upgrade the temporary credentials to token credentials and retain the
HI all, can we retain an array in NSDefualt? regards shishir
How can I keep checkboxes selected after the form has been submitted? I found
TextBox can retain the value entered in it even if the viewstate is disabled,
How can I retain client side html controls on postback? I have tried setting
A main memory can retain up to 4 pages. Which page will be the
I have a Map<String, ArrayList> and a Set<String> . Is there a way to
I'm using Emacs and Mono on Windows so that I can retain the same
My first page contains 3 tabs. I want to retain all these 3 tabs

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.