0

I would like to send variable from ctivity to another activity, but these activities are not related directely. Infact, there is 3 or 4 activities running between them.

The variable that I would like to send is the ID of the user.

I tried with creating an intent between the two activities but it did not work. Kindly help me :)

AyaAndro
  • 241
  • 1
  • 2
  • 3
  • If there are many activities between the two you can either use a singleton or pass the ID in the all the intents that happen between the two activities. – Joru Apr 01 '12 at 00:04
  • see this post [http://stackoverflow.com/questions/9960849/using-integers-strings-etc-in-other-activities][1] [1]: http://stackoverflow.com/questions/9960849/using-integers-strings-etc-in-other-activities – testingtester Apr 01 '12 at 00:30

1 Answers1

0

The "ID of the user" should be part of your data model. Your data model should be centrally accessible from all of your activities -- activities do not pass the data model to other activities. Whether you use a singleton (as one commenter suggested), or a persistent store (e.g., database), or a ContentProvider wrapped around a persistent store, is up to you.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @AyaAndro, Probably this question will help you: http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables – amp Apr 08 '12 at 20:20