当前位置: 动力学知识库 > 问答 > 编程问答 >

json - 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;

网友答案:

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/

分享给朋友:
您可能感兴趣的文章:
随机阅读: