Android examples for android.content.pm:Apk Property
get item From Apk package by unzip the apk file
import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import android.content.Context; import android.content.pm.ApplicationInfo; public class Main { public static String getChannelFromApk(Context context, String channelPrefix) { ApplicationInfo appinfo = context.getApplicationInfo(); String sourceDir = appinfo.sourceDir; String key = "META-INF/" + channelPrefix; String ret = ""; ZipFile zipfile = null;//from w w w.j a v a2s .c o m try { zipfile = new ZipFile(sourceDir); Enumeration<?> entries = zipfile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = ((ZipEntry) entries.nextElement()); String entryName = entry.getName(); if (entryName.startsWith(key)) { ret = entryName; break; } } } catch (IOException e) { e.printStackTrace(); } finally { if (zipfile != null) { try { zipfile.close(); } catch (IOException e) { e.printStackTrace(); } } } String[] split = ret.split(channelPrefix); String channel = ""; if (split.length >= 2) { channel = ret.substring(key.length()); } return channel; } }