Advertisement
Agus_Darmawan

Transfer Data Between Activity

Mar 9th, 2021
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. /* Current Activity (Sender) */
  2. Intent editScreenIntent = new Intent(ListDataActivity.this, EditDataActivity.class);
  3. editScreenIntent.putExtra("id",itemID);
  4. editScreenIntent.putExtra("name",name);
  5. startActivity(editScreenIntent);
  6.  
  7.  
  8.  
  9.  
  10.  
  11. /* Second Activity (Receiver) */
  12. //get the intent extra from the ListDataActivity
  13. Intent receivedIntent = getIntent();
  14. //now get the itemID we passed as an extra
  15. selectedID = receivedIntent.getIntExtra("id",-1); //NOTE: -1 is just the default value
  16. //now get the name we passed as an extra
  17. selectedName = receivedIntent.getStringExtra("name");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement