0

While Developing of an Intent Android application. I want to insert data in main_actvity.java and get the same data in intent_activity.java(I want to insert data in activity_main.xml and get data in intent_test.xml)

Example: I want to login(With username and password) and display my username in next screen(after logging).

Nikhil Borad
  • 2,065
  • 16
  • 20
  • 1
    You should try it yourself & search out first before asking questions here. http://stackoverflow.com/a/4967833/4489552 – Ankii Rawat Apr 30 '16 at 07:34
  • there are several options for this. tell me if you need to save the data even after the activity is killed .? – Sagar Nayak Apr 30 '16 at 11:24

2 Answers2

1

Using INTENT we can pass data from one Activity to another activity.

use INTENT for first Activity....

Intent i=new Intent(this, Next.class);//`this` is your class context and `Next.class` is another activity. 
i.putExtra("username",username.getText());
i.putExtra("password",password.getText());
startActivity(i);

use second Activity;

String username=getIntent().getStringExtra("username"),password=getIntent().getStringExtra("password");

Enjoy coding.....

sushildlh
  • 8,986
  • 4
  • 33
  • 77
0

You can use Intent as @Sushil suggested. Another way i can suggest is use of SharedPreferences. Google some good tutorials on using SharedPreferences for easy storage of app data.

Eldho Paul Konnanal
  • 500
  • 1
  • 4
  • 23