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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:38:08+00:00 2026-06-09T11:38:08+00:00

I have one activity called mylikes , it can be called from main activity

  • 0

I have one activity called mylikes , it can be called from main activity then it should display the liked items list. Another activity called programs have list of items where i press the like button and it should add that item to liked item list and display in Mylike activity.
I am adding that item to array in program activity but when i call the mylike activity from main, i am getting force close error.So how to make array list global.

  • 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-09T11:38:09+00:00Added an answer on June 9, 2026 at 11:38 am

    You can override the default application class with your own and create and use your array from there. If you have an application called MyApplication then add a class

    public class MyApplication extends Application {
    
       public ArrayList myGlobalArray = null; 
    
       public MyApplication() {
          myGlobalArray = new ArrayList(); 
       }   
    }
    

    For adding the data to array use :

    ((MyApplication)getApplicationContext()).myGlobalArray = anyarray;
    

    You can then access in an activity via something like

    ((MyApplication)getApplicationContext()).myGlobalArray ... etc.
    

    In your application manifest you also need to name your extended application class by adding the name to your application block

     <application
            android:icon="@drawable/icon"
            android:name=".MyApplication" ...
    

    If you have a globally scoped complex object that all activities need to access and you don’t want to serialize/deserialize that’s the easiest way IMO, for simpler scenarios you can pass items when you start the activity by putting extra’s into the intent

    You can also use singletons, but the application class is pretty easy to manage

    I did not test or compile code, this is just intended as an overview so watch out for typos etc.

    Here is the link for the Application class doc’s Application

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

Sidebar

Related Questions

I have two activities, one is main and I have another activity called Test
I have a Activity called main. If I call Toast.makeText(this, Hello World from main,
I have one activity which can be open from more 4 or 5 different
Lets say you have one main activity called main, and other sub-activities that do
I have one class called Global and two other activities. In each activity I
I have a design of activities like this I have one main activity and
I am trying to display ListView . I have created one activity , in
I have a database in one activity that I want to open in another
i have main activity in which i have Four menus. and i have one
i have two Activity in this i take pixels of image from one activity

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.