add data from one file to another in android studio code example

Example: add data from one file to another in android studio

String message = "Hello";

Name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(activity2.this, activity1.class);
				intent.putExtra("message", message);
				startActivity(intent);
            }
        });

// In activity1

Bundle bundle = getIntent().getExtras();
String message = bundle.getString("message");

TextView txtView = (TextView) findViewById(R.id.your_resource_textview);    
txtView.setText(message);

Tags:

Java Example