Alex Rivera | Logout

How to pass context from activity to activity?

Asked 2011-10-12T03:01:14.280
8

I have a main activity, and it summons another activity to display some data.

I have a private database helper object that I use throughout the main activity code. Is there a way to pass the context of my main activity to my sub activity in an elegant way? (ie, from subclass, something like getCallingActivityContext())

I could always create new database helper objects.

Edit
Report

1 Answer

6

Extending the Application class helps you to allow declare/access global variables. You can set your variables from any activity to ApplicationContext and access it from other activity without using bundle.

How to declare global variables in Android? will help you.

answered 2011-10-12T04:17:48.997

Your Answer