I wanted to know how Google Play app detects already installed apps so i ran a test. First, I installed an app from Google Play and extracted it's APK file. Then i started decompiling the app using ApkStudio and modified some strings. Then i did rebuilding and signing. At last, I installed the newly created APK and opened Google Play, searching app name it said that it's installed although the newly created APK file had a different hash.
Before doing this test, i thought that Google Play checks installed apps by comparing hashes of APK file but now i think it only checks by package name. Is there any reason why the checking isn't performed using hashes? I know that using hash instead of package name introduces storage overhead (as an extra hash string must be saved for every version of an app) but by doing so, one can easily find that an APK file is a modified version of another app, it's important as modified apps are malicious generally.