安卓,获取安装的应用程序的大小和日期 [英] Android, Get Installed App Size and Date
问题描述
在Android的,我怎样才能获得应用程序安装日期,我怎么可以得到安装的应用程序的大小。
In Android, How I can get app installed date and how I can get installed app size.
我使用下面code让应用程序的大小,但它是不正确的。
I am using below code to get app size but it is not correct
清单包= getPackageManager()getInstalledPackages(0);。
List packs = getPackageManager().getInstalledPackages(0);
for(i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
ApplicationInfo appInfo =p.applicationInfo;
long fileSize = new FileInputStream(appInfo.sourceDir).getChannel().size();
}
请帮我.. 谢谢你,
推荐答案
阿贾伊,
要得到你将要使用的<一个安装日期href="http://developer.android.com/reference/android/content/pm/PackageManager.html"><$c$c>PackageManager$c$c>类。更具体地,<一href="http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo%28java.lang.String,%20int%29"><$c$c>getPackageInfo()$c$c>方法。这会回报给你一个<一个href="http://developer.android.com/reference/android/content/pm/PackageInfo.html"><$c$c>PackageInfo$c$c>对象,它包含<一个href="http://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime"><$c$c>firstInstallTime$c$c>值。
To get the installation date you will want to use the PackageManager
class. More specifically the getPackageInfo()
method. This will return to you a PackageInfo
object which contains firstInstallTime
value.
还有目前不存在一个公共API来获取应用程序的大小 PackageManager.getpackageSizeInfo()
是从SDK 0.9的API拆下来SDK 1.0。请参阅<一href="http://groups.google.com/group/android-developers/browse_thread/thread/df94daae34336aad/f96a8425549c6637">HERE
There does not currently exist a public API to get an application's size as PackageManager.getpackageSizeInfo()
was removed from the API from SDK 0.9 to SDK 1.0. See HERE
祝你好运!
这篇关于安卓,获取安装的应用程序的大小和日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!