title: Android: Volley Error response 404
body: <p>Hi I am developing one android application in that I wanna user to login in into the application and during the login I will save all the data from the server by using Shared Preference. I but its just showing the Bad url error and error 404. I don't know what it is. And my code is.</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private ProgressDialog pDialog;
  
  private EditText userNameET, userPassET;
  private Button loginBtn;
  private String userType = "";//Created by Ranjani
  private String statusinfo="";
  private String url = "";
  private static String TAG = MainActivity.class.getSimpleName();
  private String carAssigningStatus,customerAssigningStatus,driverAssigningStatus;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      pDialog = new ProgressDialog(this);
      pDialog.setMessage("Please wait...");
      pDialog.setCancelable(false);
  
      userNameET=(EditText) findViewById(R.id.userNameId);
      userPassET=(EditText) findViewById(R.id.passwordId);
  
      loginBtn=(Button) findViewById(R.id.loginBtnId);
      loginBtn.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              String userNameString = userNameET.getText().toString();
              String userPassString = userPassET.getText().toString();
  
              if(userNameString == "")
                  Toast.makeText(getApplicationContext(), "Enter Username", Toast.LENGTH_LONG).show();
              else
                  if(userPassString == "")
                      Toast.makeText(getApplicationContext(), "Enter Password", Toast.LENGTH_LONG).show();
                  else
                  {
                      url = "http://www.imaginetventures.net/sample/goodmorning/rest/?type=login&amp;username="+ userNameString+"&amp;password="+userPassString;
  
  
                      //Getting information from the webserver
                      GetInfofromserver();
                  }
          }
      });
  }
  
  private void showpDialog() {
      if (!pDialog.isShowing())
          pDialog.show();
  }
  
  private void hidepDialog() {
      if (pDialog.isShowing())
          pDialog.dismiss();
  }
  protected void GetInfofromserver() {
      // TODO Auto-generated method stub
      showpDialog();
  
      JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.GET,
              url, null, new Response.Listener&lt;JSONObject&gt;() {
  
          @Override
          public void onResponse(JSONObject response) {
              Log.d(TAG, response.toString());
  
              try {
  
                          JSONObject logObj = response.getJSONObject("login");
  
                          JSONArray jArraystatus = logObj
                                  .getJSONArray("status");
  
                          // For Getting Status
                          for (int i = 0; i &lt; jArraystatus.length(); i++) {
                              JSONObject status = jArraystatus
                                      .getJSONObject(i);
                              statusinfo = status.getString("user_status");
  
                              if (statusinfo.equalsIgnoreCase("no")) {
                                  Toast.makeText(
                                          getApplicationContext(),
                                          "Username / Password does not match",
                                          Toast.LENGTH_LONG).show();
  
                              }
                          }
  
                          if (statusinfo.equalsIgnoreCase("yes")) {
  
                              JSONArray jArraytype = logObj
                                      .getJSONArray("type");
                              JSONArray jArraydriver = logObj
                                      .getJSONArray("driver");
                              JSONArray jcustomerArray = logObj
                                      .getJSONArray("customer");
                              JSONArray jcarArray = logObj
                                      .getJSONArray("car");
  
                              // For Getting Usertype Info
                              for (int i = 0; i &lt; jArraytype.length(); i++) {
  
                                  JSONObject type = jArraytype
                                          .getJSONObject(i);
  
                                  userType = type.getString("user_type");
  
                                  SharedPreferences settings = getSharedPreferences(
                                          "MyPreferences", 0);
                                  SharedPreferences.Editor editor = settings
                                          .edit();
                                  editor.putString("Login_userType", userType);
                                  editor.putString("login_Shift_Status", "no");
                                  editor.commit();
  
                                  // Log.d("*****===== ", "&gt; " +userType);
                              }
  
                              switch (userType) {
                              case "driver": {
                                  for (int i = 0; i &lt; jArraydriver.length(); i++) {
  
  
  
                                      JSONObject driver = jArraydriver.getJSONObject(i);
                                      if(driver.has("user_id"))
                                      {
                                      String user_Id = driver
                                              .getString("user_id");
                                      String name = driver.getString("name");
                                      String phone = driver
                                              .getString("phone");
                                      String photo = driver
                                              .getString("photo");
                                      String points = driver
                                              .getString("points");
  
                                      SharedPreferences settings = getSharedPreferences(
                                              "MyPreferences", 0);
                                      SharedPreferences.Editor editor = settings
                                              .edit();
                                      editor.putString("driver_user_id",
                                              user_Id);
                                      editor.putString("driver_name", name);
                                      editor.putString("driver_phone", phone);
                                      editor.putString("driver_photo", photo);
                                      editor.putString("driver_points",
                                              points);
                                      // editor.putString("driver_login_status",
                                      // login_status);
                                      editor.commit();
                                      }
                                  }
                                  for(int inc=0;inc&lt;jcustomerArray.length();inc++)
                                  {
  
                                      JSONObject customer=jcustomerArray.getJSONObject(inc);
  
                                      if( customer.has("assign_status"))
                                              {
                                                  customerAssigningStatus=customer.getString("assign_status");
                                                  if(customerAssigningStatus.equalsIgnoreCase("yes"))
                                                  {
                                                  JSONObject getcustomer=jcustomerArray.getJSONObject(inc-1);
  
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
                                                      String user_Id = getcustomer.getString("user_id");
                                                      String name = getcustomer.getString("name");
                                                      //String gender = c1.getString("gender");
                                                      //String company = c1.getString("company");
                                                      String email = getcustomer.getString("email");
                                                      //String address = c1.getString("address");
                                                      String phone = getcustomer.getString("phone");
                                                      String photo = getcustomer.getString("photo");
                                                      editor.putString("customerAssigningStatus",customerAssigningStatus );
                                                      editor.putString("customer_user_id", user_Id);
                                                      editor.putString("customer_name", name);
                                                      //editor.putString("customer_gender", gender);
                                                      //editor.putString("customer_company", company);
                                                      editor.putString("customer_email", email);
                                                      //editor.putString("customer_address", address);
                                                      editor.putString("customer_phone", phone);
                                                      editor.putString("customer_photo", photo);
  
                                                      editor.commit();
                                                  }
                                                  else
                                                  {
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
                                                      editor.putString("customerAssigningStatus",customerAssigningStatus );
                                                      editor.commit();
                                                  }
                                              }
                                              }
  
  
                                  //To Check whether the car have been assigned or not
                                  for(int inc=0;inc&lt;jcarArray.length();inc++)
                                  {
                                      JSONObject car=jcarArray.getJSONObject(inc);
  
                                      if( car.has("assign_status"))
                                              {
                                                  carAssigningStatus=car.getString("assign_status");
  
                                                  if(carAssigningStatus.equalsIgnoreCase("yes"))
                                                  {
                                                  JSONObject getcar=jcarArray.getJSONObject(inc-1);
  
  
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
  
  
  
                                                      String carId = getcar.getString("car_id");
                                                      String name = getcar.getString("car_make");
                                                      String model = getcar.getString("car_model");
  
                                                      String car_type = getcar.getString("car_type");
                                                      String color = getcar.getString("color");
                                                      String car_reg_no = getcar.getString("car_reg_no");
                                                      String model_year = getcar.getString("model_year");
                                                      String photo = getcar.getString("photo");
                                                      String mileage = getcar.getString("mileage");
                                                      Log.d("mileage ===== ",""); 
  
                                                      editor.putString("carAssigningStatus",carAssigningStatus );
                                                      editor.putString("car_user_id", carId);
                                                      editor.putString("car_name", name);
                                                      editor.putString("car_model", model);
                                                      editor.putString("car_car_type", car_type);
                                                      editor.putString("car_color", color);
                                                      editor.putString("car_car_reg_no", car_reg_no);
                                                      editor.putString("car_model_year", model_year);
                                                      editor.putString("car_photo", photo);
                                                      editor.putString("car_mileage", mileage);
                                                      editor.commit();
                                                  }
                                                  else
                                                  {
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
                                                      editor.putString("carAssigningStatus",carAssigningStatus );
                                                      editor.commit();
                                                  }
                                              }
                                              }
  
  
  
  
                                  break;
                              }
  
                              case "customer":
  
                              {
                                  for (int i = 0; i &lt; jcustomerArray.length(); i++) {
  
  
                                      JSONObject customer = jcustomerArray.getJSONObject(i);
  
                                      if(customer.has("user_id"))
                                      {
  
                                      String user_Id = customer.getString("user_id");
                                      String name = customer.getString("name");
                                      //String gender = c1.getString("gender");
                                      //String company = c1.getString("company");
                                      String email = customer.getString("email");
                                      //String address = c1.getString("address");
                                      String phone = customer.getString("phone");
                                      String photo = customer.getString("photo");
  
                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                      SharedPreferences.Editor editor = settings.edit();
  
                                      editor.putString("customer_user_id", user_Id);
                                      editor.putString("customer_name", name);
                                      //editor.putString("customer_gender", gender);
                                      //editor.putString("customer_company", company);
                                      editor.putString("customer_email", email);
                                      //editor.putString("customer_address", address);
                                      editor.putString("customer_phone", phone);
                                      editor.putString("customer_photo", photo);
  
                                      editor.commit();
                                  }
                                  }
                                  for(int inc=0;inc&lt;jArraydriver.length();inc++)
                                  {
  
                                      JSONObject driver=jArraydriver.getJSONObject(inc);
  
                                      if( driver.has("assign_status"))
                                              {
                                                  driverAssigningStatus=driver.getString("assign_status");
                                                  if(driverAssigningStatus.equalsIgnoreCase("yes"))
                                                  {
                                                  JSONObject getdriver=jArraydriver.getJSONObject(inc-1);
  
                                                  SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                  SharedPreferences.Editor editor = settings.edit();
                                                  String user_Id = getdriver.getString("user_id");
                                                  String name = getdriver.getString("name");
                                                  //String gender = c1.getString("gender");
                                                  //String company = c1.getString("company");
                                                  String email = getdriver.getString("email");
                                                  //String address = c1.getString("address");
                                                  String phone = getdriver.getString("phone");
                                                  String photo = getdriver.getString("photo");
                                                  String points=getdriver.getString("points");
                                                  String address=getdriver.getString("address");
                                                  editor.putString("driverAssigningStatus",driverAssigningStatus );
                                                  editor.putString("driver_user_id", user_Id);
                                                  editor.putString("driver_name", name);
  
                                                  editor.putString("driver_email", email);
                                                  //editor.putString("customer_address", address);
                                                  editor.putString("driver_phone", phone);
                                                  editor.putString("driver_photo", photo);
                                                  editor.putString("driver_address", address);
                                                  editor.putString("driver_points", points);
  
                                                      editor.commit();
                                                  }
                                                  else
                                                  {
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
                                                      editor.putString("driverAssigningStatus",driverAssigningStatus );
                                                      editor.commit();
                                                  }
                                              }
                                              }
  
  
                                  //To Check whether the car have been assigned or not
                                  for(int inc=0;inc&lt;jcarArray.length();inc++)
                                  {
                                      JSONObject car=jcarArray.getJSONObject(inc);
  
                                      if( car.has("assign_status"))
                                              {
                                                  carAssigningStatus=car.getString("assign_status");
  
                                                  if(carAssigningStatus.equalsIgnoreCase("yes"))
                                                  {
                                                  JSONObject getcar=jcarArray.getJSONObject(inc-1);
  
  
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
  
  
  
                                                      String carId = getcar.getString("car_id");
                                                      String name = getcar.getString("car_make");
                                                      String model = getcar.getString("car_model");
  
                                                      String car_type = getcar.getString("car_type");
                                                      String color = getcar.getString("color");
                                                      String car_reg_no = getcar.getString("car_reg_no");
                                                      String model_year = getcar.getString("model_year");
                                                      String photo = getcar.getString("photo");
                                                      String mileage = getcar.getString("mileage");
                                                      Log.d("mileage ===== ",""); 
  
                                                      editor.putString("carAssigningStatus",carAssigningStatus );
                                                      editor.putString("car_user_id", carId);
                                                      editor.putString("car_name", name);
                                                      editor.putString("car_model", model);
                                                      editor.putString("car_car_type", car_type);
                                                      editor.putString("car_color", color);
                                                      editor.putString("car_car_reg_no", car_reg_no);
                                                      editor.putString("car_model_year", model_year);
                                                      editor.putString("car_photo", photo);
                                                      editor.putString("car_mileage", mileage);
                                                      editor.commit();
                                                  }
                                                  else
                                                  {
                                                      SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                                                      SharedPreferences.Editor editor = settings.edit();
                                                      editor.putString("carAssigningStatus",carAssigningStatus );
                                                      editor.commit();
                                                  }
                                              }
                                              }
  
                                  break;
                              }
  
                              default:
                                  break;
                              }
                              SharedPreferences settings1 = getSharedPreferences("MyPreferences", 0);
                              String strValue1 = settings1.getString("car_mileage",null);
  
                              SharedPreferences settings = getSharedPreferences("MyPreferences", 0);
                              String strValue = settings.getString("Login_userType",null);
  
  
                              if(TextUtils.equals(strValue, "customer")) {
                                  Intent i = new Intent(getApplicationContext(),ClientTabMainActivity.class);
                                  startActivity(i);
                              } else if (TextUtils.equals(strValue, "driver")) {
  
                                  Intent i = new Intent(getApplicationContext(),ActivityDriverShiftView.class);
                                  startActivity(i);
  
                              }
  
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
                  Toast.makeText(getApplicationContext(),
                          "Error: " + e.getMessage(),
                          Toast.LENGTH_LONG).show();
              }
              hidepDialog();
          }
      }, new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
              VolleyLog.d(TAG, "Error: " + error.getMessage());
              Toast.makeText(getApplicationContext(),
                      error.getMessage(), Toast.LENGTH_SHORT).show();
              // hide the progress dialog
              hidepDialog();
          }
      });
  
      // Adding request to request queue
      AppController.getInstance().addToRequestQueue(jsonObjReq);
  }
  }
  </code></pre>
  
  <p>and the errors are </p>
  
  <pre><code>03-02 12:09:33.212: E/Volley(23357): [21267] BasicNetwork.performRequest: Unexpected response code 404 for http://www.imaginetventures.net/sample/goodmorning/rest/?type=login&amp;username=davidraja&amp;password=123456
  03-02 12:09:33.222: D/Volley(23357): [1] 3.onErrorResponse: MainActivity
  </code></pre>
  
  <p>Note: I wrote this code when for another url, but now the url has been changed and the old one was not in use. But the JSON data are same like previous but I don't know why its not working.</p>