title: How to create a database in CouchDB indicating the username and password
body: <p>I´m creating an android application that stores data in CouchDB, and I need to create a database from the android application. I need to execute the command "curl-X PUT <a href="http://user:passwd@127.0.0.1:5984/myDataBase" rel="nofollow">http://user:passwd@127.0.0.1:5984/myDataBase</a>" with java methods.</p>
  
  <p>I have implemented the following functions:</p>
  
  <pre><code>public static boolean createDatabase(String hostUrl, String databaseName) {
      try {
          HttpPut httpPutRequest = new HttpPut(hostUrl + databaseName);
          JSONObject jsonResult = sendCouchRequest(httpPutRequest);
  
          return jsonResult.getBoolean("ok");
      } 
      catch (Exception e) {
          e.printStackTrace();
      }
      return false;
  }
  
  private static JSONObject sendCouchRequest(HttpUriRequest request) {
      try {
          HttpResponse httpResponse = (HttpResponse) new DefaultHttpClient().execute(request);
          HttpEntity entity = httpResponse.getEntity();
          if (entity != null) {
              InputStream instream = entity.getContent();
              String resultString = convertStreamToString(instream);
              instream.close();
              JSONObject jsonResult = new JSONObject(resultString);
  
              return jsonResult;
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>I call the function by:</p>
  
  <pre><code>createDatabase("http://user:passwd@127.0.0.1/","myDataBase");
  </code></pre>
  
  <p>but there is no result. I think the problem is in user:passwd because in "admin party" mode the funcion works fine calling by:</p>
  
  <pre><code>createDatabase("http://127.0.0.1/","myDataBase");
  </code></pre>