Download url to app files directory example
1. This post is about downloading a file from its url to getFilesDir() of the app. Similar code can be used to download to getCacheDir() with little modification. 2. In permission manager add INTERNET permission. 3. Create a java class file LinkHelper.java and put following codes in it. (Change package name to package name of your app). package com.my.newproject5; import android.content.Context; import android.net.Uri; import android.os.Handler; import android.os.ParcelFileDescriptor; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; public class LinkHelper { // INTERFACES public interface DownloadCallback { void onProgress(int percent); // 0 → 100 void onSuccess(File file); void onError(String message); } // ASYNC FILE DOWNLOAD WITH PROGRESS LISTENER public static void downloadToAppDataAsyn...