<span id="Label3"></p>At present, the domestic market is rampant, Android phone upgrade is a one-day, for the original old phone may not sdcard, resulting in our app can not download resources, can not update the app, for this situation has the following solutions.<br>Use the following function to determine if there is an SD card and then determine which directory to Download.<p><p></p></p><pre class="brush:objc;gutter:true;">/** * Install application */public static void update (File apkfile, context Context) {Intent Intent = new Intent (intent.action_view); if ( Apkfile = null && apkfile.exists ()) {chmod (apkfile.getabsolutepath ());//authorization intent.setdataandtype ( Uri.fromfile (apkfile), "application/vnd.android.package-archive"); intent.setflags (intent.flag_activity_new_task ); context.startactivity (intent);} else {mlog.maketext ("installation failed, installation File not found");}} public static void chmod (string pathc) {string chmodcmd = "chmod 666" + pathc;try {runtime.getruntime (). exec (chmodcmd);} Catch (Exception e) {e.printstacktrace ();}} public static Boolean ismounted () {return environment.getexternalstoragestate (). equals (environment.media_mounted);} /** * The location where the initial file can be stored * @param context */public static void init (context Context) {fileutil.context = context; StringBuffer buffer = new StringBuffer (); String PName = context.getpackagename (); if (tools.ismounted ()) {buffer.append ( Environment.getexternalstoragedirectory (). getabsolutepath ()); buffer.append (file.separator); buffer.append (pName); filedir = buffer.tostring ();} else {buffer.append (context.getfilesdir (). getabsolutepath ()); buffer.append (file.separator); buffer.append (pName) ; filedir = buffer.tostring ();} File File = new file (filedir), if (!file.exists ()) file.mkdir ();}</pre><p><p> </p></p><p><p></p></p> <ul> <ul> <li>This article fixed link: http://www.ithtw.com/910.html</li> <li>Reprint please specify: Leehom January 22, 2015 in it 100,000 why published</li> </ul> </ul><p><p>Android Internal Storage Install APK file implementation</p></p></span>
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