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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:41:49+00:00 2026-06-08T11:41:49+00:00

I have the following List: List<Map<String, String>> items = new ArrayList<Map<String, String>>(); It’s populated

  • 0

I have the following List:

List<Map<String, String>> items = new ArrayList<Map<String, String>>();

It’s populated with data on the load of my app. I need to use it throughout my entire app, on most Activities and Fragments, with data both being read and being modified.

What is the best and simplest way to make this global without too much complexity?

Note: For reasons that are too much to explain on Stack Overflow, this much be used a List and not as a custom Object with properties.

  • 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-08T11:41:51+00:00Added an answer on June 8, 2026 at 11:41 am

    other posts are missing the point. of course he can store the list as an instance member and access it with getters and setters, but what object owns the member?

    you can use statics as has been suggested, but there’s a better way … just hang it off of your application class. create a class that extends Application, and add the instance there,

    public class MyApplication extends Application { 
        private List<Map<String, String>> items = new ArrayList<Map<String, String>>();
    
        public List<Map<String, String>> getItems() {
            return items;
        }
    
        public void setItems(List<Map<String, String>> items) {
          this.items = items;
        }
    }
    

    configure the application class into your manifest,

    <application
        android:name=".MyApplication"
        ...
    

    now, in your activities, or services, just do this,

    List<Map<String, String>> items = ((MyApplication)getApplication()).getItems();
    

    from your fragments, do this,

    List<Map<String, String>> items = ((MyApplication)getActivity().getApplication()).getItems();
    

    and the nice thing is that this object has the same lifecycle as your application. it exists while any part of your application is active, and gets GC’d along with your application.

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

Sidebar

Related Questions

I have the following ArrayList ArrayList<HashMap<String, String>> list; HashMap<String, String> map; with the following
I have the following code: List<int> intList = new ArrayList<int>(); for (int index =
I have the following function that iterates over a list [(Map String SqlValue)] extractPatternStrings
I have the following list of tuples: items = [ ('john jones', ['Director', 'Screenwriter',
I have the following List<int> collection and I need to find the highest integer
If we have the following list: list = ['UMM', 'Uma', ['Ulaster','Ulter']] If I need
I have the following code object DispatchLibrary { private var nodes = Map.empty[java.util.UUID, List[BigInt]]
I have the following query method that has slow performance: @Override public Map<String, Long>
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I have the following list of pairs of data: pairs = {{3, John}, {1,

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.