Download google drive link in Sketchware
This post shows how to download files from Google Drive in Sketchware to Downloads folder.
1. Create a new project in Sketchware pro.
2. In google drive, make access of your files public.
3. In main.xml add two EditText edittext_drivelink, edittext_filename; two TextViews text_id, text_link, and three Buttons button_id, button_download, button_clear.
4. In Permission manager, add INTERNET permissions.
5. Create a more block of type String, name extractId [String url]. Put following codes in it.
if (_url == null) return "";
String regex =
"(?<=/d/|id=|folders/)[a-zA-Z0-9_-]{10,}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(_url);
return matcher.find() ? matcher.group() : "";
6. Create a more block startDownload [String url][String filename] and put following codes in it.
DownloadManager.Request request =
new DownloadManager.Request(Uri.parse(_url));
request.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS,
_filename
);
request.setNotificationVisibility(
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
);
request.allowScanningByMediaScanner();
request.setTitle("Downloading file");
request.setDescription(_filename);
DownloadManager dm =
(DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
dm.enqueue(request);
7. Create four String variables url, id, downloadUrl, filename.
8. In button_id onClick event, extract id from url and create downloadUrl by joining https://drive.google.com/uc?export=download&id= and id.
9. In button_download onClick event, download the file using downloadUrl and filename.
10. In button_clear onClick event, reset all TextViews and EditText.
11. Save and run the project.
12. In edittext_drivelink, paste google drive link of your file and click Extract Id. Then write file name and click Download.




I always rely on TechGoodTips for practical tech solutions. Their guides are clear and easy to follow, making complicated topics simple. TechGoodTips truly helps me stay updated with the latest trends and tips. Highly recommended for all tech enthusiasts!
ReplyDeleteI’m genuinely impressed by TechPaer commitment to quality content. The website’s user-friendly design makes browsing a pleasure. TechPaer covers diverse tech topics in a way that’s both engaging and educational. It’s my go-to source for reliable tech updates.
ReplyDeleteWhenever I need reliable tech advice, I turn to
ReplyDeleteTechElsa. The website offers insightful articles and practical solutions. TechElsa’s user-friendly layout makes navigation smooth, and the quality of information is outstanding. I appreciate their dedication to helping users.