Code snippet: Get all User installed apps on Android

In App List I needed to get the list of all user installed apps. So I made this little utility function:

	public List<PackageInfo> getInstalledPackages()
	{
		List<PackageInfo> allPackages = getPackageManager().getInstalledPackages(0);
		List<PackageInfo> installedPackages = new ArrayList<PackageInfo>();
		for(PackageInfo p : allPackages) //parse all packages to remove the ones with "System" flag
		{
			if(!((p.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM)) //package is not marked as "System"
			{
				installedPackages.add(p);
			}
		}
		return installedPackages;
	}

I hope this helps.

3 thoughts on “Code snippet: Get all User installed apps on Android”

Leave a Reply

Your email address will not be published. Required fields are marked *