0

I am new in android app Development my task is to upload data to localhost server that a user will (fill a form & press submit button to) upload.Tell also if any library is needed.

thanks in advance.

2

1 Answer 1

1

Are you using an HTML page? If so it is like a normla html page where you have a form with your fields and a submit button. If you have, instead, a UI and wants to upload the data to a remove server there are several options:

  • Manually
  • Using some library (OkHttp or Volley)

If you want to do it manually:

 HttpURLConnection con = (HttpURLConnection) ( new URL(url)).openConnection(); con.setRequestMethod("POST"); con.setDoInput(true); con.setDoOutput(true); con.connect(); con.getOutputStream().write( ("name=" + name).getBytes()); InputStream is = con.getInputStream(); byte[] b = new byte[1024]; while ( is.read(b) != -1) buffer.append(new String(b)); con.disconnect(); 

Hope it helps you! If you like i wrote a post about it in my blog

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.