Home > DeveloperSection > Forums > how to send value from one class into different classes(more than one class)
Jeet Verma
Jeet Verma

Total Post:110

Posted on    May-15-2013 7:53 AM

 Java Java 

 1 Reply(s)
 851  View(s)
Rate this:
Hi Everyone!

I have value strUser and KEY ,I want to send this value to multiple different classes because this value will be used in 5 classes for url, I know the way to send value to one class only using Intent.putExtra as bellow :

Intent policy= new Intent(LoginActivity.this,EpolicyListPolis.class);
How can I send this value to multiple different classes at a time? can i use SharedPrefences..? how the way i write sharedPrefences in class and my destination class?

Thanks in advance! 


Total Post:604

Posted on    May-15-2013 8:41 AM

Hi Jeet!

Try as following

send value from this class with Intent....

Intent policy= new Intent(LoginActivity.this,EpolicyListPolis.class);

this works like: KEY-"key" and VALUE-strUser. and you get this value from another class using KEY.

Get value like this.

String user = getIntent().getExtras().getString("key",null);
in user you get strUser value. and if strUser not pass any value than default null(right side of "key") assign for user....

same you use from all class you need... but remember all works with KEY...

because KEY(one type of ID) is only which is works to Put and Get particular value.....

I hope  it helpful for you!

Don't want to miss updates? Please click the below button!

Follow MindStick