Download Uri to file

This commit is contained in:
lionel 2021-03-05 11:36:19 +01:00
parent 4612b1a994
commit 54dce31f53
4 changed files with 6 additions and 8 deletions

View File

@ -277,7 +277,7 @@ public class Transfer {
return fileList;
}
public void downloadFile(final Uri uri, String name, long fileSize, String href, Button button) throws IOException {
public void downloadFile(final File file, String name, long fileSize, String href, Button button) throws IOException {
/*final LinearLayout layout = activity.findViewById(id);
final Button button;
@ -286,8 +286,6 @@ public class Transfer {
else
button = null;*/
final File file = new File(uri.getPath());
URL url = null;
HttpURLConnection conn = null;
int maxBufferSize = 1 * 1024 * 1024;

View File

@ -302,13 +302,13 @@ public class DownloadFragment extends Fragment {
final String href = (String) layout.getTag(R.id.ID_FILE_HREF);
new File(save_location).mkdirs();
Uri uri = Uri.fromFile(new File(save_location, name));
File file = new File(save_location, name);
Transfer tr = new Transfer();
new Thread(() -> {
try {
tr.downloadFile(uri, name, fileSize, href, button);
tr.downloadFile(file, name, fileSize, href, button);
} catch (IOException e) {
final String ExceptionName = e.getClass().getSimpleName();
final String ExceptionMess = e.getMessage();

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Mon Jan 11 18:53:24 CET 2021
#Thu Feb 18 20:04:28 CET 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip