This is definitely possible. If your application is running as root, it can access the wallet files of Bitcoin wallets, which usually have fixed filenames and file headers. The downside of this approach is if there's a vulnerability in your software, someone can steal Bitcoins from your customers and install malware.
How else could this be done? A Bitcoin wallet could implement an API so that applications on the same phone can query the Bitcoin balance. There is definitely an argument for making this possible. I wouldn't compare it to rifling through a purse when entering a department store - it's most similar to how DigitalOcean charges me a cent and cancels the charge to test that my credit card is valid, before it rents servers to me.
As Andreas Schildbach says, this is intentionally not implemented. (Note that Schildbach is the maintainer of this Android wallet, and one of the contributors to BitcoinJ, which many Android wallets use behind the scenes.) Why wouldn't you want this feature? One reason is that many applications are supported by advertising/data collection. If this API were made available, many applications with no reason to have this information would ask for it. You can imagine that those companies would sell datasets that include email addresses and Bitcoin balances - the primary effect of this feature would be to add another vector to phish Bitcoin users.
1Although it might not be your intent, you are essentially asking how to write malware. How much money someone has in their wallet is not the business of another app, so I don't believe there are any wallets that expose this. This is like a department store looking through your wallet or purse when you walk in the door. It's an invasion, and not a reputable thing to be doing. – Jestin – 2017-01-04T16:42:50.653
i fundamentally disagree with this. you wrongly assume i haven't first asked for permission for this information. i'm happy to register an app with first asks for this permission. requesting to pay N bitcoins and watching it fail is akin to knowing that fact, and that can be done via BIP20 but messily – Kimbrough Software – 2017-01-04T19:42:04.267
Be that as it may, but I am still unaware of any wallet apps that allow other apps to query this information. Likely, this is for security reasons. It shouldn't be the responsibility of your application to check if the user can afford a purchase prior to attempting to bill the user. – Jestin – 2017-01-04T19:52:10.830
it ought to be a basic feature of wallet functionality that permissioned users know various permissioned facts about it . – Kimbrough Software – 2017-01-04T20:46:42.233
to my mind this new paradigm in the digital manipulation of money which bitcoin represents ought to include the ability to replace what used to be done by humans with algorithms, properly permissioned, operating on wallets. For example, HD wallets in particular can express corporate structure. Saying something like "it shouldn't be the responsibility of your application" to know these facts about the place where an entity stores all its keys is overly restrictive. I'd like to be in a position to know ad hoc if a department in my company was running a surplus or deficit. – Kimbrough Software – 2017-01-04T23:20:56.783
U may find this irrelevant but given the initial analogy I want to add that if u call a bank and ask if a person has enuff funds to cover a check the person has written out to you, the bank will tell u yes or no. When I ran a business, I would do this to prevent depositing a check that resulted in me being charged fees for insufficient funds if the person's check bounced. Seems like there would be something similar with bitcoins, especially since I normally do not know the persons with whom I'm exchanging coins. – Suzanne Moody – 2017-08-04T01:18:14.330