MohanRaj S
MohanRaj S

Reputation: 2008

Shared preference value as input to the JSONArray in Android

How to pass the shared preference values as input to the JSONArray, I'm using the following code in my program, Kindly Help me,Thanks in Advance.

shared prefernce to get email id pref = getApplicationContext().getSharedPreferences("set", 0); editor = pref.edit();

Put the Shared Preference Value in RegisterActivity

editor.putString("email", inc_email.getText().toString());

Get the value from Shared Preference in LoginActivity

pref = getApplicationContext().getSharedPreferences("set", 0); final String em=pref.getString("email","");

Parsing Value to service URL

String API="http://groups.com/projects/nic/main.php?email="+em+"&state="+state;

Upvotes: 0

Views: 281

Answers (1)

Idipaolo
Idipaolo

Reputation: 788

Do you forgot to commit changes?

Try:

editor.putString("email", inc_email.getText().toString());
editor.commit();

If you need JSON parsing, you may use this useful library https://jsonp.java.net/

Upvotes: 2

Related Questions