Accessing file created externally on SD card

Erik :

I'm trying to create a universal android app that will be deployed on a number of provisioned/managed chromeboxes, and I need to be able to reliably identify each device. Because they are managed devices without dedicated user accounts, each reboot generates a new Android ID.

I don't want to have to create a different app for each one with an ID hardcoded, so my thought was to get a bunch of SD cards and from a PC add a simple file to each with an ID in it, and have the app read the file. I can't find a reliable way to access those files from the app though.

Environment.getExternalStorageState() has been depreciated, getExternalFilesDir returns the path to memory dedicated to the app, and nothing I've tried with the MediaStore will show files created outside of the app.

Any ideas?

Erik :

As it turns out, you can't actually access those files from within the app (thanks CommonsWare).

As far as identifiers, with the READ_PHONE_STATE permission you can use the Build.getSerial() function get the hardware serial number, so no SD card needed afterall!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=11786&siteId=1
Recommended