Fix getPath issues that arise on Android 4.4

This is an update to PR #6811. It includes the changes in that PR, and it fixes the spacing issues.