Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

global varible for application  RSS feed

 
sam liya
Ranch Hand
Posts: 1254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a global varible for my android application.is there a good way to do this ?
I have several activities.I need to use this variable for all these activities.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define it in your strings.xml and access it via context.getString(int id)
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, if the value can change at runtime, extend Application.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!