﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-只有奋斗的过程才是最真实的-随笔分类-Andriod</title><link>http://www.cnitblog.com/aimilo2008/category/8909.html</link><description>幸福</description><language>zh-cn</language><lastBuildDate>Fri, 08 Jun 2012 02:52:43 GMT</lastBuildDate><pubDate>Fri, 08 Jun 2012 02:52:43 GMT</pubDate><ttl>60</ttl><item><title> android 2.2上最简单实现将软件默认装到SD卡中的方法！</title><link>http://www.cnitblog.com/aimilo2008/archive/2012/06/08/81022.html</link><dc:creator>大源</dc:creator><author>大源</author><pubDate>Fri, 08 Jun 2012 02:39:00 GMT</pubDate><guid>http://www.cnitblog.com/aimilo2008/archive/2012/06/08/81022.html</guid><wfw:comment>http://www.cnitblog.com/aimilo2008/comments/81022.html</wfw:comment><comments>http://www.cnitblog.com/aimilo2008/archive/2012/06/08/81022.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aimilo2008/comments/commentRss/81022.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aimilo2008/services/trackbacks/81022.html</trackback:ping><description><![CDATA[<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; table-layout: fixed; width: 783px; color: #444444; font-family: Tahoma, Helvetica, SimSun, sans-serif; font-size: 12px; line-height: 18px; "><tbody style="word-wrap: break-word; "><tr style="word-wrap: break-word; "><td id="postmessage_6293503" style="word-wrap: break-word; "><span style="font-size: 14pt; ">1.root.(这个不用解释了吧!)</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">2.安装超级终端(在论坛搜,一搜一把).</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">3.启动超级终端,输入命令:su</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">4.然后输入命令:pm setInstallLocation 2</span><br style="word-wrap: break-word; " /><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">解释:</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">第3步,是使超级终端获取root权限;</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">第4步,是将默认程序安装位置设置为SD卡(代码为2).</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; "><br />如果想再设置回手机,再在超级终端中做第3步,然后第4步中,将代码设置为0即可!</span><br style="word-wrap: break-word; " /><span style="font-size: 19px;"></span><br style="word-wrap: break-word; " /><span style="font-size: 19px;"><br style="word-wrap: break-word; " /></span><span style="font-size: 14pt; ">Android 2.2固件中的pm命令支持安装选项参数，新增了参数setInstallLocation，这里我们可以用adb通过shell命令执行 linux的pm添加一些参数即可，如: adb shell pm setInstallLocation 0</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">其中最后一个参数0代表auto自动的，Android系统会自动选择，而1为手机内部的rom，2为外部sd卡存储，主要说明如下</span><br style="word-wrap: break-word; " /><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">adb shell pm setInstallLocation option</span><br style="word-wrap: break-word; " /><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">option 的值可以为以下数字</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">&nbsp; &nbsp;&nbsp; &nbsp; 0&nbsp; &nbsp;&nbsp;&nbsp;[auto] Let the system decide. 自动</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">&nbsp; &nbsp;&nbsp; &nbsp; 1&nbsp; &nbsp;&nbsp;&nbsp;[internal only] ROM中</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">&nbsp; &nbsp;&nbsp; &nbsp; 2&nbsp; &nbsp;&nbsp;&nbsp;[external] SD卡中</span><br style="word-wrap: break-word; " /><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">推荐大家对于经常用的小软件可以安装在手机内部，比如来电管理、系统工具这样可以提供更高的可靠性节省电量，而游戏类和APK文件比较大的(超过4MB) 应用可以考虑安装到SD卡上</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">通过电脑墙纸让apk安装到sd卡的命令为</span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">adb shell pm setInstallLocation 2&nbsp;<br /></span><br style="word-wrap: break-word; " /><span style="font-size: 14pt; ">另外，还有新的获取安装的位置参数为getInstallLocation，我们使用adb shell pm getInstallLocation来获取软件的安装位置列表。<br /><br /></span><br style="word-wrap: break-word; " /><span style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; font-size: 14pt; ">Android文档的App Install Location里面提到了这部分&nbsp;</span><br style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; text-align: left; background-color: #ffffff; " /><span style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; font-size: 14pt; ">主要是manifestAdditions的配置&nbsp;</span><br style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; text-align: left; background-color: #ffffff; " /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; color: #000000; line-height: 25px; text-align: left; "><div class="bar"><div class="tools" style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://xuliduo.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%3Candroid%3E%0A%20%20%20%20%3CmanifestAdditions%3E%0A%20%20%20%20%20%20%20%20%3C!%5BCDATA%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cmanifest%20android%3AinstallLocation%3D%22auto%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cuses-permission%20android%3Aname%3D%22android.permission.INTERNET%22%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fmanifest%3E%0A%20%20%20%20%20%20%20%20%5D%5D%3E%0A%20%20%20%20%3C%2FmanifestAdditions%3E%0A%3C%2Fandroid%3E%0A" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://xuliduo.iteye.com/blog/1044559" title="收藏这段代码" style="color: #006600; text-decoration: underline; "><img class="star" src="http://xuliduo.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" class="dp-xml" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="tag" style="color: #006699; font-weight: bold; ">&lt;</span><span class="tag-name" style="color: #006699; font-weight: bold; ">android</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag" style="color: #006699; font-weight: bold; ">&lt;</span><span class="tag-name" style="color: #006699; font-weight: bold; ">manifestAdditions</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="cdata" style="color: #ff1493; ">&lt;![CDATA[</span>&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="cdata" style="color: #ff1493; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;manifest&nbsp;android:installLocation="auto"&gt;</span>&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="cdata" style="color: #ff1493; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;uses-permission&nbsp;android:name="android.permission.INTERNET"/&gt;</span>&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="cdata" style="color: #ff1493; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/manifest&gt;</span>&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="cdata" style="color: #ff1493; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]]&gt;</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag" style="color: #006699; font-weight: bold; ">&lt;/</span><span class="tag-name" style="color: #006699; font-weight: bold; ">manifestAdditions</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="tag" style="color: #006699; font-weight: bold; ">&lt;/</span><span class="tag-name" style="color: #006699; font-weight: bold; ">android</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li></ol></div><br style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; text-align: left; background-color: #ffffff; " /><span style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; font-size: 14pt; ">其中： android:installLocation="</span><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; color: red; font-size: 14pt; ">auto</span><span style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; font-size: 14pt; background-color: #ffffff; ">"代表默认安装到内置存储器中，但是允许用户把它转移到SD卡上。&nbsp;</span><span style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; font-size: 14pt; ">而如果需要默认安装在SD卡上，只需要&nbsp;</span><br style="color: #000000; font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 25px; text-align: left; background-color: #ffffff; " /><div class="dp-highlighter" id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; background-color: #ffffff; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; color: #000000; line-height: 25px; text-align: left; "><div class="bar"><div class="tools" style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://xuliduo.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%3Cmanifest%20android%3AinstallLocation%3D%22preferExternal%22%3E...%3C%2Fmanifest%3E%0A" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://xuliduo.iteye.com/blog/1044559" title="收藏这段代码" style="color: #006600; text-decoration: underline; "><img class="star" src="http://xuliduo.iteye.com/images/icon_star.png" alt="收藏代码" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; " /></a></div></div><ol start="1" class="dp-xml" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span class="tag" style="color: #006699; font-weight: bold; ">&lt;</span><span class="tag-name" style="color: #006699; font-weight: bold; ">manifest</span>&nbsp;<span class="attribute" style="color: red; ">android:installLocation</span>=<span class="attribute-value" style="color: blue; ">"preferExternal"</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>...<span class="tag" style="color: #006699; font-weight: bold; ">&lt;/</span><span class="tag-name" style="color: #006699; font-weight: bold; ">manifest</span><span class="tag" style="color: #006699; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li></ol></div><span style="font-size: 14px;"><br /></span></td></tr></tbody></table><img src ="http://www.cnitblog.com/aimilo2008/aggbug/81022.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aimilo2008/" target="_blank">大源</a> 2012-06-08 10:39 <a href="http://www.cnitblog.com/aimilo2008/archive/2012/06/08/81022.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>