This will do the trick...cheers :)
PackageManager pm = getPackageManager();
List<PackageInfo> list = pm.getInstalledPackages(0);
for (PackageInfo pi : list) {
ApplicationInfo ai;
try {
ai = pm.getApplicationInfo(pi.packageName, 0);
System.out.println(">>>>>>packages is<<<<<<<<" + ai.publicSourceDir);
// this condition if satisfied means the application currently refered by ai
// variable is
// a system application
if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
Log.d(getClass().getSimpleName(), ">>>>>>packages is system package" + pi.packageName);
}
} catch (NameNotFoundException e) {
Log.d(getClass().getSimpleName(), "Name not found", e);
}
}