In Android: How do I get variables/data from one screen to another?

First Activity

Intent myIntent = new Intent();
myIntent.putExtra("key", "value");
startActivity(myIntent); 

New Activity

Intent myIntent = getIntent(); // this is just for example purpose
myIntent.getExtra("key");

Check out the different types you can use on the Android Dev Site

Note: If you’re looking for a way of sharing an object/data globally then you could extend the Application class. Check out How to declare global variables in Android? (answer by Soonil)

Leave a Comment