Trying to download a file from inside an Android application - android

I'm trying to download a file from within my application. I've set a button's onClickListener to call this method:
private void downloadFile(String fileUrl, File destDir, String fileName) {
try {
URL url = new URL(fileUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.connect();
if (destDir.isDirectory() && !destDir.exists()) {
destDir.mkdirs();
}
FileOutputStream output = new FileOutputStream(new File(destDir.toString() + "/" + fileName));
InputStream input = connection.getInputStream();
byte[] buffer = new byte[1024];
int byteCount = 0;
while ((byteCount = input.read(buffer)) != -1) {
output.write(buffer, 0, byteCount);
}
output.close();
input.close();
} catch (IOException e) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e("IOException", "Error: " + e.getMessage(), e);
} finally {
Toast.makeText(this, "File downloaded: " + fileName, Toast.LENGTH_SHORT).show();
}
}
I've been going through various topics, but neither one seemed to come up with a usable solution. When I use the code specified above, nothing seems to happen.
EDIT: The file will download in the background and show a short toast when finished. The button seems to be "clicked" while downloading, though. Any thoughts on this?
Thanks for your help!
Actually I didn't need all that code. I just had to use something similar to this:
private void getFile(String url) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e("ActivityNotFoundException", "Error: " + e.getMessage(), e);
} catch (NullPointerException e) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e("NullPointerException", "Error: " + e.getMessage(), e);
}
}
This should also be useful to some people:
private void openFile(File file) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e("ActivityNotFoundException", "Error: " + e.getMessage(), e);
} catch (NullPointerException e) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Log.e("NullPointerException", "Error: " + e.getMessage(), e);
}
}

If nothing happens, you should add some logging to your code.
And you could also show the error to the user, by calling Toast.makeText(context, ex.getMessage(), Toast.LENGTH_SHORT).show()
Better would be to show the root cause message using helper methods like these:
public static String getRootCauseMessage(Throwable ex) {
ex = getRootCause(ex);
String message = ex.getLocalizedMessage();
return message == null ? ex.getClass().getSimpleName() : message;
}
public static Throwable getRootCause(Throwable ex) {
Throwable cause = ex.getCause();
return cause == null ? ex : getRootCause(cause);
}

Related

HttpURLConnection POST response gets lost when server takes longer to respond

I'm having trouble catching a response to a POST request to server, when the server takes a bit longer to respond (when it is passed a bigger JSONObject).
When we call a GET method with a longer response time, there is no problem. When we call a POST and pass a relatively small JSONObject, the method registers a response.
The method is being called from an AsyncTask via new Task().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR).
When triggered from Postman, the response returns after 155 seconds, but it arrives. On the other hand, when triggered from the app, the code does nothing and ultimately tiggers a SocketTimeoutException.(For whatever reason, we have a timeout(connection and read timeout) set to 10 minutes) The code snippet for the service method is below. I'd appreciate any hints.
public static JSONObject requestWebService(String serviceUrl, JSONObject jsonObject) throws Exception {
private static final int CONNECTION_TIMEOUT = 1000 * 600;
private static final int DATARETREIVAL_TIMEOUT = 1000 * 600
HttpURLConnection urlConnection = null;
try {
URL urlToRequest;
String message;
urlToRequest = new URL(serviceUrl);
urlConnection = (HttpURLConnection) urlToRequest.openConnection();
urlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
urlConnection.setReadTimeout(DATARETREIVAL_TIMEOUT);
if (jsonObject != null) {
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json");
message = jsonObject.toString();
OutputStream os = new BufferedOutputStream(urlConnection.getOutputStream());
os.write(message.getBytes());
os.flush();
os.close();
} else {
urlConnection.setRequestMethod("GET");
}
int statusCode = urlConnection.getResponseCode();
if (statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new Exception("Acces unauthorized " + statusCode + ".");
} else if (statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception("Server unavailable " + statusCode + ".");
}
return new JSONObject(ReplicationClient.convertInputStreamToString(urlConnection.getInputStream()));
} catch (MalformedURLException e) {
fileLogger.error(logHeader + e.getMessage(), e);
throw new Exception("Error " + e.getMessage(), e);
} catch (SocketTimeoutException e) {
fileLogger.error(logHeader + e.getMessage(), e);
throw new Exception("Error " + e.getMessage(), e);
} catch (IOException e) {
fileLogger.error(logHeader + e.getMessage(), e);
throw new Exception("Error " + e.getMessage(), e);
} catch (JSONException e) {
fileLogger.error(logHeader + e.getMessage(), e);
throw new Exception("Error " + e.getMessage(), e);
} catch (Exception e) {
fileLogger.error(logHeader + e.getMessage(), e);
throw new Exception("Error " + e.getMessage(), e);
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
}
after a second thought i have a theory
i will explain in details
but first try this code for writing data:
remove this from your code:
OutputStream os = new BufferedOutputStream(urlConnection.getOutputStream());
os.write(message.getBytes());
os.flush();
os.close();
use this:
OutputStream os = urlConnection.getOutputStream();
os.write( message.getBytes());
os.close();
if this works, then i will edit this answer and explain more.
This answer did not help as per the OP comment.
I am keeping this in case i found something else, otherwise, i will delete it later.

How to send file between device using xmpp while chat

Thanks for paying attention over the question...
I am making a XMPP chat application with the help of ejabbered and asmack_4.1 library.
I have installed a PSI client for windows to chat with the android device.
I am able to perform text chat between devices.
I am also able to send file from device to PSI client and PSI client to android device.
But the problem is to send files device to device.
I am using below code to send and receive files :
File send :
public void fileTransfer(String filenameWithPath, Bitmap thumbnail, String userId) {
// FileTransferManager manager = new FileTransferManager(connection);
FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
// OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("usre2#myHost/Smack");
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(userId + "/Admin"); // "/Good" depends on server
// OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(userId + "/Directors-iMac");
File file = new File(filenameWithPath);
try {
transfer.sendFile(file, "test_file");
} catch (SmackException e) {
e.printStackTrace();
}
while (!transfer.isDone()) {
if (transfer.getStatus().equals(FileTransfer.Status.error)) {
System.out.println("ERROR!!! " + transfer.getError());
} else if (transfer.getStatus().equals(FileTransfer.Status.cancelled)
|| transfer.getStatus().equals(FileTransfer.Status.refused)) {
System.out.println("Cancelled!!! " + transfer.getError());
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (transfer.getStatus().equals(FileTransfer.Status.refused) || transfer.getStatus().equals(FileTransfer.Status.error)
|| transfer.getStatus().equals(FileTransfer.Status.cancelled)) {
System.out.println("refused cancelled error " + transfer.getError());
} else {
System.out.println("Success");
}
}
File Receiving :
public void fileReciever(AbstractXMPPConnection connection) {
//**************************************
// Create the file transfer manager
final FileTransferManager managerListner = FileTransferManager.getInstanceFor(connection);
// FileTransferNegotiator.setServiceEnabled(connection, true);
FileTransferNegotiator negotiator = FileTransferNegotiator.getInstanceFor(connection);
Log.i("File transfere manager", "created");
// Create the listener
managerListner
.addFileTransferListener(new FileTransferListener() {
#Override
public void fileTransferRequest(FileTransferRequest request) {
Log.i("Recieve File", "new file transfere request new file transfere request new file transfere request");
Log.i("file request", "from" + request.getRequestor());
IncomingFileTransfer transfer = request.accept();
Log.i(RECIEVE_FILE_ALERT_DIALOG, "accepted");
try {
transfer.recieveFile(new File("/sdcard/" + request.getFileName()));
while (!transfer.isDone() || (transfer.getProgress() < 1)) {
Log.i(RECIEVE_FILE_ALERT_DIALOG, "still receiving : " + (transfer.getProgress()) + " status " + transfer.getStatus());
if (transfer.getStatus().equals(FileTransfer.Status.error)) {
// Log.i("Error file",
// transfer.getError().getMessage());
Log.i("Recieve File",
"cancelling still receiving : "
+ (transfer.getProgress())
+ " status "
+ transfer.getStatus());
transfer.cancel();
break;
}
}
} /*catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/ catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
//**************************************
}
Note : In fileTransfer() method, I am using below line:
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(userId + "/Admin"); // "/Good" depends on server
I am able to send files from Android device to PSI desktop application and vice versa but i am not able to transfer files between android devices.

Unable to receive file using asmack and XMPP

I'm working on file sharing using Asmack and XMPP. I am able to send file but not able to receive file on another device. I did so much of Research and Development, found so many ways tried all of them but haven't got success. Seems I am making any small mistake, tried a lot but haven't got solution for my problem. The code I used for sending file is:
d.findViewById(R.id.btnsendphoto).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (!filepath.equals("")) {
configureProviderManager(connection);
FileTransferNegotiator.IBB_ONLY = true;
FileTransferNegotiator.setServiceEnabled(
connection, true);
mFileTransferManager = new FileTransferManager(
connection);
String to = connection.getRoster()
.getPresence("cac6ba9dc9c6ac67#pc")
.getFrom();
final OutgoingFileTransfer transfer = mFileTransferManager
.createOutgoingFileTransfer(to);
File file = new File(filepath);
try {
configureProviderManager(connection);
transfer.sendFile(file, "test_file");
} catch (XMPPException e) {
e.printStackTrace();
}
new AsyncTask<Void, Void, Void>() {
protected void onPreExecute() {
}
#Override
protected Void doInBackground(
Void... params) {
while (!transfer.isDone()) {
if (transfer.getStatus().equals(
"Error")) {
Log.d("file transfer",
"ERROR!!! "
+ transfer
.getError());
} else if (transfer.getStatus()
.equals("Cancelled")
|| transfer.getStatus()
.equals("Refused")) {
Log.d("file transfer",
"Cancelled!!! "
+ transfer
.getError());
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
};
protected void onPostExecute(Void result) {
if (transfer.getStatus().equals(
"Refused")
|| transfer.getStatus().equals(
"Error")
|| transfer.getStatus().equals(
"Cancelled")) {
Log.i("file transfer",
"refused cancelled error "
+ transfer
.getError());
} else {
Log.i("file transfer", "Success: "
+ transfer.getFileName());
messages.add("file sent");
setListAdapter();
}
};
}.execute();
}
d.dismiss();
}
});
I am able to send file. I got this message file sent on sending side, here configureProviderManager is this
and I have tried many ways that I got on Google but I would like to mention one of those here
First is:
public void ReceiveFile() {
System.out.println("in ReceiveFile");
Thread thread = new Thread() {
public void run() {
System.out.println("in Thread");
configureProviderManager(connection);
// Create the file transfer manager
final FileTransferManager managerListner = new FileTransferManager(
connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
Log.i("File transfere manager", "created");
// Create the listener
managerListner
.addFileTransferListener(new FileTransferListener() {
public void fileTransferRequest(
final FileTransferRequest request) {
Log.i("Recieve File",
"new file transfere request");
Log.i("file request",
"from" + request.getRequestor());
IncomingFileTransfer transfer = request
.accept();
Log.i("Recieve File alert dialog", "accepted");
try {
transfer.recieveFile(new File("/sdcard/"
+ request.getFileName()));
while (!transfer.isDone()
|| (transfer.getProgress() < 1)) {
Thread.sleep(1000);
Log.i("Recieve File alert dialog",
"still receiving : "
+ (transfer
.getProgress())
+ " status "
+ transfer.getStatus());
if (transfer.getStatus().equals(
Status.error)) {
// Log.i("Error file",
// transfer.getError().getMessage());
Log.i("Recieve File alert dialog",
"cancelling still receiving : "
+ (transfer
.getProgress())
+ " status "
+ transfer
.getStatus());
transfer.cancel();
break;
}
}
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
};
thread.start();
}
Debugging this code
I am not even getting this log new file transfer request. Kindly please tell what mistake I am making and how can I correct this.

Dropbox Sync API Android - Updating Cached Files

I am facing trouble in updating the existing cached file within my Android Application.
for(DbxFileInfo fInfo : fileList)
{
Log.d(TAG, "File Path = "+fInfo.path.toString());
String fileName = fInfo.path.getName().trim();
try
{
DbxPath tempFilePath = new DbxPath(fInfo.path.toString());
DbxFile tempFile = mDbFileSystem.open(tempFilePath);
if(tempFile.getSyncStatus().isCached)
{
Log.v(TAG, "File is already cached !");
if(tempFile.getSyncStatus().isLatest)
{
Log.v(TAG, "File's Latest Version is Cached !");
}
else
{
Log.v(TAG, "File's Latest Version is not Cached !");
}
}
try
{
tempFile.getNewerStatus();
}
catch(Exception dBException)
{
Log.e(TAG, "Error while getting newer Status !");
}
InputStream input = new BufferedInputStream(tempFile.getReadStream());
OutputStream output = new FileOutputStream(cntx.getFilesDir() + "/SyncedData/" + fileName);
byte data[] = new byte[1024];
int count;
//total size is in Bytes
while ((count = input.read(data)) != -1)
{
totalBytesDownloaded += count;
publishProgress((int) (totalBytesDownloaded * 100/totalFileSize));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
tempFile.close();
mDbFileSystem.delete(tempFile.getPath());
result = true;
}
catch(Exception e)
{
Log.e(TAG, "Error occured while downloading files !, Error = "+e.toString());
result = false;
}
}
I am putting different files with same names on my Synced Dropbox folder and after Downloading them i am getting the older version of files.
Is there any way i can update my existing cached files or Clear the Dropbox Cache (that is within my App)
Any help is highly appreciated, thanks.
Here's how the Sync API works:
It constantly syncs metadata (what files exist and their revisions) and notifies you via listeners you set up on the file system.
For open files, it downloads any newer version of the file available and notifies you via the listener you set up on the file itself.
So if you want to get the latest version of a file, you need to open the file and hold it open while waiting for the listener to notify you that the newer version of the file is cached. Then you can call update to get access to that new data.
EDIT: Pasting code from https://www.dropbox.com/developers/sync/start/android#listeners:
DbxFileStatus status = testFile.getSyncStatus();
if (!status.isCached) {
testFile.addListener(new DbxFile.Listener() {
#Override
public void onFileChange(DbxFile file) {
// Check testFile.getSyncStatus() and read if it's ready
}
});
// Check if testFile.getSyncStatus() is ready already to ensure nothing
// was missed while adding the listener
}
Here is my attempt to get the latest file but as I stated in the comment to your question, it seems I sometimes have to do two sync calls in order to get the latest file.
The fileModified and fileSize comparison is rather crude but seems to do the trick. Better than what I have found so far at least.
public DropboxFileDownloader() {
super("FileDownloader");
}
#Override
protected void onHandleIntent(Intent intent) {
String turiosHome = intent.getStringExtra(Constants.EXTRA_HOME);
String fileName = intent.getStringExtra(Constants.EXTRA_FILENAME);
String folderPath = intent.getStringExtra(Constants.EXTRA_FOLDERPATH);
ResultReceiver receiver = intent.getParcelableExtra(Constants.EXTRA_RECEIVER);
Bundle bundle = new Bundle();
String fullpath = folderPath + "/" + fileName;
DbxFile file;
long fileModified = 0;
long fileSize = 0;
try {
file = dbxFs.open(new DbxPath(fullpath));
try {
DbxFileStatus fileStatus = file.getNewerStatus();
if (fileStatus != null && !fileStatus.isLatest) {
/*while (file.getNewerStatus().pending == PendingOperation.DOWNLOAD) {
Log.d(TAG, "Waiting for " + fileName + " to be downloaded");
Thread.sleep(1000);
}*/
if (fileStatus.isCached) {
//Start of Edit
try
{
//Running this do while loop until the Latest version of this file is cached.
do
{
Log.d(TAG, "Updating the existing file !");
//Updating the file
file.update();
while (file.getNewerStatus().pending ==PendingOperation.DOWNLOAD)
{
Log.d(TAG, "Waiting for " + fileName+ " to be downloaded");
Thread.sleep(1000);
}
} while (fileStatus.isLatest);
}
catch (Exception dBException)
{
Log.e(TAG, "Error while getting newer Status !, Error = "+dBException.toString());
dBException.printStackTrace();
}
//End of Edit
}
}
fileModified = file.getInfo().modifiedTime.getTime();
fileSize = file.getInfo().size;
} catch (DbxException e) {
Log.e(TAG, e.getMessage(), e);
bundle.putString(Constants.EXTRA_MESSAGE, e.getMessage());
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_ERROR, bundle);
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (InvalidPathException e1) {
Log.e(TAG, e1.getMessage(), e1);
bundle.putString(Constants.EXTRA_MESSAGE, e1.getMessage());
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_ERROR, bundle);
return;
} catch (DbxException e1) {
Log.e(TAG, e1.getMessage(), e1);
bundle.putString(Constants.EXTRA_MESSAGE, e1.getMessage());
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_ERROR, bundle);
return;
}
File stored_dir = new File(turiosHome + "/" + folderPath);
if (!stored_dir.exists()) {
stored_dir.mkdirs();
}
File stored_file = new File(turiosHome + "/" + folderPath,
fileName);
// File stored_file = getFileStreamPath(fileName);
long local_modified = stored_file.lastModified();
long local_size = stored_file.length();
boolean should_sync = (fileModified > local_modified)
|| fileSize != local_size;// && Math.abs(fileModified -
// local_modified) >
// TimeUnit.MILLISECONDS.convert(1,
// TimeUnit.MINUTES);
boolean fileexists = stored_file.exists();
if (should_sync || !fileexists) {
InputStream inputStream = null;
FileOutputStream out = null;
try {
// read this file into InputStream
inputStream = file.getReadStream();
out = new FileOutputStream(stored_file);
int read = 0;
byte[] bytes = new byte[1024];
int bytes_counter = 0;
while ((read = inputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
bytes_counter++;
}
Log.d(TAG, "Wrote: " + file.getPath().getName() + " "
+ bytes_counter + " kb");
if (!fileexists) {
bundle.putString(Constants.EXTRA_FILEPATH, fullpath);
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_CREATED, bundle);
} else {
bundle.putString(Constants.EXTRA_FILEPATH, fullpath);
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_UPDATED, bundle);
}
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
bundle.putString(Constants.EXTRA_MESSAGE, e.getMessage());
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_ERROR, bundle);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
if (out != null) {
out.flush();
out.close();
}
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
bundle.putString(Constants.EXTRA_MESSAGE, e.getMessage());
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_ERROR, bundle);
}
}
}
else {
bundle.putString(Constants.EXTRA_FILEPATH, fullpath);
receiver.send(DropboxFileDownloaderResultReceiver.RESULTCODE_UPTODATE, bundle);
}
file.close();
}
}
I can't found working example for me. But for my case - i don't need cashed version of files - only newest (data synchronization between devices).
I used
mDbFileSystem.setMaxFileCacheSize(0);
All or nothing. But now nessasary thread for downloading in background.

File not found when uploading database file into dropbox

I have completed one android application and integrated DropBox to my application to upload a database.When i am uploading a single file it will be upload correctly.My problem is when i get the db file from my application and uploading this to dropbox it show file not found exeception.I am also using this link but not get solution.
Link
FileInputStream inputStream = null;
try {
String databasePath=getDatabasePath("databaseTaskApps.db").getPath();
Log.i(TAG,"DatabasePath:"+databasePath);
File file = new File(databasePath+ "/databaseTaskApps");
inputStream = new FileInputStream(file);
com.dropbox.client2.DropboxAPI.Entry newEntry = mApi.putFileOverwrite("/databaseTaskApps", inputStream,
file.length(), null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
} catch (DropboxUnlinkedException e) {
// User has unlinked, ask them to link again here.
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} catch (DropboxException e) {
Log.e("DbExampleLog", "Something went wrong while uploading.");
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
Log.e("DbExampleLog", "File not found.");
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
Hai i found answer for my question
File[] files = new File("/data/data/com.dropbox.android.sample/databases/").listFiles();
for (File f:files) {
if (f.getName().equals("databaseTaskApps"))
{
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(f);
com.dropbox.client2.DropboxAPI.Entry newEntry = mApi.putFileOverwrite("/databaseTaskApps", inputStream,
f.length(), null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
} catch (DropboxUnlinkedException e) {
// User has unlinked, ask them to link again here.
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} catch (DropboxException e) {
Log.e("DbExampleLog", "Something went wrong while uploading.");
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
Log.e("DbExampleLog", "File not found.");
Toast.makeText(getApplicationContext(), "Not Uploading", Toast.LENGTH_SHORT).show();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
}
}

Categories

Resources