How to download files from server to a plugin's internal storage directory

85 Views Asked by At

I have an app called MyNiceApp installed in the internal storage /data/app/com.myniceapp.root_pkg.

QUESTIONS 1

Is it possible to programatically download files into /data/app/com.myniceapp.root_pkg

QUESTIONS 2

MyNiceApp is the core app that only contains the main core view that is to be populated by views generated by plugins that a user will download in APK format from my server as wishes.

Is it possible to download these plugin APKs from a personal server into this directory (/data/app/com.myniceapp.root_pkg) and launch the views into the main core view?

I'm thinking it would be better organized if I had a folder created under /data/app/com.myniceapp.root_pkg/plugins, then have DexClassLoader crawl /data/app/com.myniceapp.root_pkg/plugins for downloaded plugins, then I could call my Class implementations, and dynamically load the plugin views to the core view at runtime.

Thank you all in advance.

1

There are 1 best solutions below

0
On

Answer 1:
There is a sample (SOF question) for downloading.
If u would like write to an internal directory you can use this:
File myDir = context.getDir("MyInternalDirectory", Context.MODE_PRIVATE);
That will create a directory in your package folder (comment: the 'context' is not needed if you are in the main thread).

Answer 2:

Working on it....

I hope this will help.