Android Network Load Dynamic Library.

Source: Internet
Author: User

These days to do the project encountered a problem, a total of 17M apk, only two. So files accounted for 14M, just try to install the user after the app, according to the user needs to load. So files, after the search, the method is not complicated.

1. The network download portion of the. So file is not displayed,

2.. so file storage path: General recommendations are stored under the data/data/<packagename>/path with the following code:

    //Getfiledir ():/data/data/<packagename>/file/File file2 =NewFile (Getfilesdir (), "libbankeyscoreapi.so"); Try {            //fos = openfileoutput ("libbankeyscoreapi.so", context.mode_private);//The first parameter: file name, do not allow to include delimiter "/", if the file does not exist, Android will automatically create//second parameter: Specify the mode of operation
It is recommended to use this, but after the test will be saved, the hint "/data/data/<packagename>/app_" is a path error
I'm giving up on this way
FOS =NewFileOutputStream (File2.getabsolutefile ()); Fos.write (b); Fos.close (); LOG.E ("TAG", "" "+true+ ";" +File2.getabsolutepath ()); } Catch(FileNotFoundException e) {e.printstacktrace (); LOG.E ("TAG", E.getmessage ()); } Catch(IOException e) {e.printstacktrace (); LOG.E ("TAG", E.getmessage ()); } System.load (File2.getabsolutepath ());

In addition: Lib Lower library will generally be backed up under/data/data/<packagename>/lib/, call method to make a change, as follows:

System.loadlibrary ("");

Also, attach:

Getpackagecodepath ():/data/app/com.example.download.sotest-2.apk
Getfilesdir ():/data/data/com.example.download.sotest/files
Getpackageresourcepath ():/data/app/com.example.download.sotest-2.apk
Getcachedir ():/data/data/com.example.download.sotest/cache
Getexternalcachedir ():/storage/emulated/0/android/data/com.example.download.sotest/cache
Getobbdir ():/storage/emulated/0/android/obb/com.example.download.sotest
Getfilesdir ():/data/data/com.example.download.sotest/files

The above part I tried after is feasible, hoped can help everybody.

Android Network Load Dynamic Library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.