0
votes

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;

1

1 Answers

2
votes

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/