Search code examples
javaandroidkindle-fire

Amazon Kindle Fire HD Saving Files onto MicroSD Cards


Before It gets brought up about my question already being asked, I would like to state that I have tried around 5 other options and possible solutions with no result.

Here is a snippet of my code. This is just a snippet. Upon testing the results of my code currently, a file is being saved in the main directory, /ScoutingApp. However, I would like to files to save in a folder /ScoutingApp/ on the MicroSD card so I can eject data more quickly.

        if (Environment.MEDIA_MOUNTED.equals(state)) {
        File root = Environment.getExternalStorageDirectory();
        File Dir = new File(root.getAbsolutePath() + "/ScoutingApp");
        if (!Dir.exists()) {
            Dir.mkdir();
        } else {

            filename = UUID.randomUUID().toString() + ".sql";
            File file = new File(Dir, filename);

Solution

  • If the Android that your Fire OS is based on is Android 4.4+, you can try getExternalFilesDirs() on any Context (such as an Activity). Note the plural form — if this method returns 2+ items, the second and subsequent ones are on removable storage. Those locations will be specific for your app, and you can read from and write to those locations without permissions.

    Note, though, that Fire OS is not completely compliant with the Play ecosystem's compatibility requirements, and so YMMV.