php - Pass a shared preference value using StringRequest so I can filter my SQL query -


i'm working on listview inside fragment. it's working fine, need filter data on listview using user's username. how able pass "username" using request? help, advice, , tip appreciated. in advance :)

here's code:

public class pendingfragment extends fragment {     public static final string json_url = "my_url";     private listview listview;     @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         final view rootview = inflater.inflate(r.layout.pending_layout,null);          //fetching username shared preferences         sharedpreferences sharedpreferences = getactivity().getsharedpreferences(config.shared_pref_name, context.mode_private);         string username = sharedpreferences.getstring(config.username_shared_pref,"not available");          sendrequest();         listview = (listview) rootview.findviewbyid(r.id.listview);         return rootview;     }      private void sendrequest(){         stringrequest stringrequest = new stringrequest(json_url,                 new response.listener<string>() {                     @override                     public void onresponse(string response) {                         showjson(response);                     }                 },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror error) {                         toast.maketext(pendingfragment.this.getactivity(),error.getmessage(),toast.length_long).show();                     }                 });          requestqueue requestqueue = volley.newrequestqueue(pendingfragment.this.getactivity());         requestqueue.add(stringrequest);     }      private void showjson(string json){         //showjson function     }  } 

you can append user's username parameter url if get request , post request can use other constructor of stringrequest class,

volley post example

the above link contains samples get , post request , can overview of said,


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -