Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to send hashmap from one activity to another

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.59k
    Comment on it

    HashMap is basically an implementation of map and this is not synchronized. HashMap basically contains key value pair data.

    From sending activity we can create and send hashmap value like this :

    HashMap<String, String> mHashMap= adapter.getItem(position);
    Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
    intent.putExtra("hashMap", mHashMap);
    startActivity(intent);
    

    Second Activity: in our second activity we can get hashMap data but using getSearializedExtra like this :

    Intent intent = getIntent();    
    HashMap<String, String> hashMap = (HashMap<String, String>) intent.getSerializableExtra("hashMap");
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: