Tag Archives: setRequestMethod

Upload bigger files from Android to server – Example

By | March 23, 2017

Below is the function which uploads bigger files from Android device to Server. [java] public String sendFileToServer(String filename, String targetUrl) { String response = "error"; Log.e("Image filename", filename); Log.e("url", targetUrl); HttpURLConnection connection = null; DataOutputStream outputStream = null; // DataInputStream inputStream = null; String pathToOurFile = filename; String urlServer = targetUrl; String lineEnd = "\r\n"; String twoHyphens =… Read More »

How to Download a PDF File and open it in Android using an installed PDF Reader?

By | March 6, 2013

Actually this is fairly simple. This simple code does this. [java] Uri path = Uri.fromFile(downloadFile(download_file_url)); try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } catch (ActivityNotFoundException e) { setError("PDF Reader application is not installed in your device"); } [/java] Here is the complete program that shows how to download a PDF File and open… Read More »

How to read and write files to SDCARD and application SandBox in Android – A complete example?

By | September 6, 2012

Here is a complete example of How to read and write files to SDCARD and application SandBox in Android. First create a new project and inside the mainActivity paste this code. [java] package com.coderzheaven.filesexample; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity implements OnClickListener { EditText edittext;… Read More »

How to download a file to your android device from a remote server with a custom progressbar showing progress?

By | April 29, 2012

Actually this is really simple. I have already posted an example for how to download a file in this post. How to Download an image in ANDROID programatically? This is another one little different with a progressbar included. Previously I have shown three other methods to upload files to a server. Check these posts to refer this. 1.… Read More »

Uploading audio, video or image files from Android to server

By | March 29, 2012

Hello everyone, Check out the popular posts from Coderzheaven.com Uploading and Downloading of files – Popular and Useful posts from CoderzHeaven In one of the previous posts I have shown one method to upload an image in android. Here is another method to upload a media file like images,audio or video in android. Here is the main java… Read More »