Android : Android - Getting SharedPreferences and putting it in a class

on Sunday, March 22, 2015


I have this class wherein it gets the sharedPreferences put it in a variable and use that variable to $POST to my PHP file.



public class NetworkOperations extends AsyncTask<String,Void,String> {

String awesomeString = PreferenceManager.getDefaultSharedPreferences(this).getString("key", "");

@Override
protected String doInBackground(String... arg0) {

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://usamobileapp.pe.hu/webservice/viewGradesJSON.php");
try {
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(1);
nameValuePair.add(new BasicNameValuePair("id", "somevalue"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
HttpResponse response = httpClient.execute(httpPost);
Log.d("Http Response:", (response.getEntity()).toString());
} catch (ClientProtocolException e) {

} catch (IOException e) {
e.printStackTrace();
} finally {
httpClient.getConnectionManager().shutdown();
}
return null;
}

}


Here's the problem:


this is underlined red


I'm a beginner so I don't seem to grasp what the problem is.


Thank you for the help.


0 comments:

Post a Comment