Let's say you want to pass the contents of a string with a putExtra from one activity to another, for example, I have an intent that goes from one class to another, and when I take the UserEdit class a putExtra with the tag " Name "and after the comma the content that must carry Name, which is of type string
adapter.getItem(position).getNombre()
this line returns a String with a name and stores it with the Tag "Name"
Intent intent = new Intent(MainActivity.this, UserEdit.class);
intent.putExtra("Nombre",adapter.getItem(position).getNombre());
Now, to get this value in my other activity
Intent iin= getIntent();
Bundle b = iin.getExtras();
if(b!=null)
{
String n =(String) b.get("Nombre");
Log.e("El nombre es: ",""+n);
}else{
Toast.makeText(this, "No se pudo traer el Extra", Toast.LENGTH_SHORT).show();
}
I just create a getIntent, and a Bundle which gets the extras, check that is different from null to confirm that it comes with some content, and then I put b.get ("Name") and get the Name from my other activity
This is how it works to get data from one activity to another