Wednesday, October 14, 2015

How to Insert value to server database with android

AndroidManifest


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />


class Your_Method_Name extends AsyncTask<String, String, String> {

    /**     * Before starting background thread Show Progress Dialog     */    @Override    protected void onPreExecute() {
        super.onPreExecute();
        
    }

    /**     * adding messages     */    protected String doInBackground(String... args) {

        

        // Building Parameters        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("Your_Key", Your_value));
       

        // getting JSON Object
        JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);

        //for checking        Log.d("Create Response", json.toString());

        // check for success tag        try {
            int success = json.getInt(SUCCESS);

            if (success == 1) {

            } else {

            }
        } catch (JSONException e) {

            e.printStackTrace();
        }

        return null;
    }

    /**     * After completing background task Dismiss the progress dialog     * *     */    protected void onPostExecute(String file_url) {

       
    }

}