Get HashMap data from another Activity

Filip Luchianenco

I have used this tutorial to save session. I still don't understand how to get this data from another activity.

 public HashMap<String, String> getUserDetails(){
    HashMap<String, String> user = new HashMap<String, String>();
      user.put(KEY_FULLNAME, pref.getString(KEY_FULLNAME, null));        
      user.put(KEY_EMAIL, pref.getString(KEY_EMAIL, null));

    // return user
    return user;
}

I found out people are using intent to send it to another activity like in this link. Is there a simple way to get the data like i call methods from another activity(import the class, then give a variable var for that class, and call the method like var.theMethodFromClass()).


Update

public SessionManager(Context context){
    this._context = context;
    pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
    editor = pref.edit();
}

this function is in my SessionManager class, how can i use it directly, without initializing all variables again, as they are already initialized in the activity in order to be used.

the full code of SessionManager.class is in the first link

kalyan pvs

You are already saved your data in the SharedPrefernces so why you need to send it from one Activity to another Activity..Try to open the SharedPreference file in Another Activity and Use it as you like..

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

To get data from another activity

From Dev

passing a HashMap from one activity to another, android

From Dev

How to get ListView data from one activity to another using setOnClickListener

From Dev

How to get value from listview and passing JSON data to another Activity

From Dev

How to get the data from an activity to another and use them?

From Dev

How to get data from onitemclick and display it on another activity (Android Dev)?

From Dev

How to get ListView data from one activity to another using setOnClickListener

From Java

Pass data from Activity to Fragment in another Activity

From Dev

How to get ArrayList from another activity to Another

From Dev

get data from hashmap into highcharts

From Dev

HashMap Store and Restore onSaveInstanceState from Fragment to another Activity

From Dev

How to get the data from the database created by another activity/ Fails to update data into database (Android studio,SQLite)

From Dev

How To Get Value From another Activity?

From Dev

Get reference to object from another activity

From Dev

Get text from edit text to another activity

From Dev

Get text from EditText into string to another activity

From Dev

Sending data from one activity to another startactivityforresult

From Dev

Passing data from one activity to another and then printing

From Dev

How to retrieve data in spinner from another activity?

From Dev

Notifying data change from one activity to another

From Dev

Sending data from one activity to another startactivityforresult

From Dev

Calling activity from another app that stores data

From Dev

transferring data from string arrays into another activity

From Dev

Transfer data from one activity to another

From Dev

How to parse data from one activity to another

From Dev

Passing json data from an activity to another with AsyncTask

From Dev

without moving next activity Send data from another activity in android

From Dev

without moving next activity Send data from another activity in android

From Dev

How to pass the data from listview of one activity and pass it to another activity?

Related Related

  1. 1

    To get data from another activity

  2. 2

    passing a HashMap from one activity to another, android

  3. 3

    How to get ListView data from one activity to another using setOnClickListener

  4. 4

    How to get value from listview and passing JSON data to another Activity

  5. 5

    How to get the data from an activity to another and use them?

  6. 6

    How to get data from onitemclick and display it on another activity (Android Dev)?

  7. 7

    How to get ListView data from one activity to another using setOnClickListener

  8. 8

    Pass data from Activity to Fragment in another Activity

  9. 9

    How to get ArrayList from another activity to Another

  10. 10

    get data from hashmap into highcharts

  11. 11

    HashMap Store and Restore onSaveInstanceState from Fragment to another Activity

  12. 12

    How to get the data from the database created by another activity/ Fails to update data into database (Android studio,SQLite)

  13. 13

    How To Get Value From another Activity?

  14. 14

    Get reference to object from another activity

  15. 15

    Get text from edit text to another activity

  16. 16

    Get text from EditText into string to another activity

  17. 17

    Sending data from one activity to another startactivityforresult

  18. 18

    Passing data from one activity to another and then printing

  19. 19

    How to retrieve data in spinner from another activity?

  20. 20

    Notifying data change from one activity to another

  21. 21

    Sending data from one activity to another startactivityforresult

  22. 22

    Calling activity from another app that stores data

  23. 23

    transferring data from string arrays into another activity

  24. 24

    Transfer data from one activity to another

  25. 25

    How to parse data from one activity to another

  26. 26

    Passing json data from an activity to another with AsyncTask

  27. 27

    without moving next activity Send data from another activity in android

  28. 28

    without moving next activity Send data from another activity in android

  29. 29

    How to pass the data from listview of one activity and pass it to another activity?

HotTag

Archive