Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing data among Activities

 
Jake Reynolds
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got an idea for an application, but it's going to end up having a lot of variables that I'd like to stay static, both across application launches and Activities (I can think of at least two that I'd be using). What's the best way to handle this? A single row sqlite db? Writing the variables out to a file? Creating an object to hold them then pass it to the activities, and serialize it on pause?

Thanks,
--Jake
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
android.app.Activityclass has methods called getExtras(..) and putExtras(..) that you can use to pass data around. You can use android.os.Bundle to pass data between activities(it is serializable too).
 
Jake Reynolds
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohhhh, I saw that put to work in Hello, Android and hadn't even thought of it... Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic