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

The Archive Base Latest Questions

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

Possible Duplicate: Passing data between activities in Android Ok Lets say that in my

  • 0

Possible Duplicate:
Passing data between activities in Android

Ok Lets say that in my Activity1.java there is a variable called date

If I declare it as static, in my Activity2 I can recall its value just by writing Activity1.date.

If it’s not static I can when starting activity2 pass the value of date via Bundle.

Both ways are working.

My question is which is most preffered and has less disadvantages?

  • 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-09T13:00:01+00:00Added an answer on June 9, 2026 at 1:00 pm

    Static is bad for many reasons, primarily because it is umm… static. It means that it will be always taking memory and also you will have only one instance of your field to share across all instances of your activity.

    Because of this it can you bite your in so many places in so many subtle ways. For instance – if you write several unit tests for the same activity, the value will be shared, therefore your tests will not be independent. Or another use case: you have several instances of your activity on the stack – they all will share the value, which in many cases is not what you want.

    The bottom line: do not do static. Static can save you a line or two of code but can introduce a lot of trouble. By the way it is not specific to android, it is true for any platform

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

Sidebar

Related Questions

Possible Duplicate: Passing only two variables between controller and view - best practice? There
Possible Duplicate: php4 with json data Is there a library or class that provides
Possible Duplicate: Passing data between asp.net pages how to pass value of TEXTBOX from
Possible Duplicate: Passing Data between View Controllers I sometime using passing data between viewcontroller
Possible Duplicate: Passing Data between View Controllers iOS dev noob here.. I have a
Possible Duplicate: Passing Data between View Controllers I have 2 modal views. The first
Possible Duplicate: Xcode: Storyboard Tabbed Application Passing Data Back and Forth Basically I have
Possible Duplicate: C#: Passing null to overloaded method - which method is called? Here
Possible Duplicate: In PHP (>= 5.0), is passing by reference faster? Say I'm dealing
Possible Duplicate: Sending and Parsing JSON in Android I am fetching JSON Data from

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.