title: How to secure webservice URL?
body: <p>I have an android app with web service urls. If anyone decrypts my apk file, the webservice url will become visible.I am using  HTTP POST for calling web service.</p>
  
  <p>Anyone can read the code by decompiling the apk file from <a href="http://www.javadecompilers.com" rel="nofollow noreferrer">this site</a>.</p>
  
  <p>My registration page url got hacked and sending bulk request to this url with post data. I was using a <code>API_KEY</code> and send the <code>API_KEY</code> with post data. <code>API_KEY</code> was stored in <code>gradle.properties</code> file.  </p>
  
  <p>I did not used</p>
  
  <pre><code> minifyEnabled true
   shrinkResources true
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'`  when its got hacked.
  </code></pre>
  
  <p>After some search, i know that there is no 100% secure methods to hide url. </p>
  
  <p>My code for registration is :</p>
  
  <pre><code>String link = "http://xxxxxxxxxx.php";
  
  String data = URLEncoder.encode("name", "UTF-8") + "=" + URLEncoder.encode(name, "UTF-8");
  data += "&amp;" + URLEncoder.encode("phone", "UTF-8") + "=" + URLEncoder.encode(phone, "UTF-8");
  data += "&amp;" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); 
  
  URL url = new URL(link);
  URLConnection conn = url.openConnection();
  conn.setDoOutput(true);
  OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
  wr.write(data);
  wr.flush();
  </code></pre>
  
  <p>I don't know if it is the correct method to post data to a Url.</p>
  
  <p>How can i secure my source code?</p>
  
  <p>Can i store all my web service url in server?</p>
  
  <p>I am beginner to android. Please help!</p>