I am trying to calculate the size of the installed application.
I found an answer here
I have tested it on some devices, and there is no problem except Sams
Maybe this link will help you:
http://nsamteladze.blogspot.com/2012/10/get-apks-code-size-in-android.html
Basically he is making use of the concept of reflection, which is a powerful tool but not always advisable. Read more about it here :What is reflection and why is it useful? and if it is suitable for you, make use of it.