2

I have a button in my Native App(Cordova) :

<li><a href="myapp.apk" download="myapp.apk">Download</a></li>

The button download is not working on mobile... And I would like, when download's finished, that the apk file opens automatically.

Louys Patrice Bessette
  • 33,375
  • 6
  • 36
  • 64
Vende Achat
  • 183
  • 1
  • 2
  • 10

1 Answers1

0

Problem seems like in your path. If you have the apk stored in somewhere in server, you can provide the path of the file. For example

<a href="http://www.thegadgettechie.com/wp-content/uploads/2016/08/hello-1.jpg" download="hello">Download link</a>

This will download the image specified in href tag. Make sure your url starts with 'http'. If you didn't specify a path which didn't start with http, cordova will look for the file with respect to the root folder (where your index.html is located).

So if you simply specify

 <a href="myApp.apk" download="myApp">Download link</a>

This will look for the file myApp.apk inside the root folder of your app. The above code will work if your myApp.apk is indside your www folder.

www ---- index.html ---- myApp.apk ---- app.js

So based on the location of the file, you specify path.