Extract app icon in Android

Android has been on my radar for a long time, but I could never proceed with simple hello world program and few basic stuffs. From last couple of months, I have been working with both Hybrid and Native application development for Android. The experience has been enriching as I have explored lot of things in Android App Development. There are still few areas (testing, automation, profiling, game development etc.) that yet to be discovered. While developing one of the functionality, I came across a strange problem. The need was to extract an icon of any installed app and store it. Later the extracted icons must be displayed in GridView for user actions. I started using following code, to extract and save the icon

Drawable appIcon = packageManager.getApplicationIcon("");
BitmapDrawable bitmapIcon = (BitmapDrawable)appIcon;
FileOutputStream fosIcon = context.openFileOutput(packageName + ".png", Context.MODE_PRIVATE);
bitmapIcon.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, fosIcon);
//flush stream... close stream...