Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an object accessible to all activities in an Android program?

I have an application which consists of two activities/screens and a java class from which i create objects.

I need to use an object I created on the first activity (instanciating the .java class) on the second activity.

What is the simplest way to do this? I googled about it and implementing the Parcelable interface on the java class seems to be the most common answer to this problem. But the object is kind of complex and parceling every single member of it seems like a brute-force solution.

Isn't there an elegant solution to this?

Thanks

EDIT: Is storing the object data on a simple SQlite database a solution?

like image 998
tyb Avatar asked Jan 18 '12 00:01

tyb


1 Answers

You could use the application context (although this is basically storing global state so you need to be careful how you're using it):

Using Application context everywhere?

like image 96
Abdullah Jibaly Avatar answered Oct 19 '22 12:10

Abdullah Jibaly