How to include additional local files in apk?

Hi,

I have built my app and it uses some additional local files that I load in this way:

$http.get('/data/mydata.json').success(function(data) {
        $scope.mydata = data;
  });

Everything works perfect on my PC (because the files exist) but if I build apk file and I transfer it to the phone or if I execute ionic run it doesn’t work, because the files are not in the phone.

How can I include these aditional files into the apk?

Thanks

Can’t those local files be kept in the www folder ? If they can I think they should get copied in to the app.

If above is not the case then you may try writing a cordova hook. I haven’t used cordova for a while, but I think I had done something similar.

You might check the third hook in this post - http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/

Thanks Dbms!

You are right. The files were inside www folder but for some reason I added the initial slash ‘/’ in the route that was causing the error.

Thanks!

Jorge

1 Like