Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4066300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:06:57+00:00 2026-05-20T16:06:57+00:00

I have an Android app which by preference uses external storage if available to

  • 0

I have an Android app which by preference uses external storage if available to store various files but will use internal storage if external storage is unavailable.

I’ve extended Application and maintain a static File for the app’s working directory as follows…

public class MyApp extends Application {
    protected static File myFilesDir = null;
    protected static Helper myHelper = null;

    @Override
    public void onCreate() {
        super.onCreate();

        myHelper = new Helper(this);
        if (myHelper.CanWriteExtStorage()) {
            Log.d(TAG, "onCreate() - myHelper.CanWriteExtStorage() returned TRUE");
            myFilesDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + packageName + "/files");
        }
        else {
            Log.d(TAG, "onCreate() - myHelper.CanWriteExtStorage() returned FALSE");
            myFilesDir = new File(getFilesDir().getAbsolutePath());
        }
        myFilesDir.mkdirs();

        if (!myFilesDir.equals(null)) {
            Log.d(TAG, "onCreate() - myFilesDir: " + myFilesDir.getAbsolutePath());
}

The app is currently being beta-tested by some people I’m in direct contact with and one guy commented that he thought I was supposed to be using the SD card if available but he could see from logcat the app was using /nand/Android/data... I asked what /nand referenced and he said it is internal memory on his pad/tablet device.

The code the Helper class uses to check for external storage is as follows…

protected boolean CanWriteExtStorage() {
    boolean mExternalStorageWriteable = false;
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state))
            mExternalStorageWriteable = true;
    return mExternalStorageWriteable;
}

…but the relevant log output is as follows…

D/com.mycompany.myapp(3844): onCreate() - myHelper.CanWriteExtStorage() returned TRUE
D/com.mycompant.myapp(3844): onCreate() - myFilesDir: /nand/Android/data/com.company.myapp/files

So, the question is why, when I’m able to test that the external storage state shows it is mounted, would Environment.getExternalStorageDirectory() return a path to what appears to be internal storage?

Should I be testing for something other than Environment.MEDIA_MOUNTED or is there just something strange about this device or Android version (he is running v2.1).

In the long run it possible doesn’t matter but I’m concerned my logic is incorrect for certain devices.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:06:57+00:00Added an answer on May 20, 2026 at 4:06 pm

    Read the documentation for Environment.getExternalStorageDirectory()

    Note: don’t be confused by the word
    “external” here. This directory can
    better be thought as media/shared
    storage. It is a filesystem that can
    hold a relatively large amount of data
    and that is shared across all
    applications (does not enforce
    permissions). Traditionally this is an
    SD card, but it may also be
    implemented as built-in storage in a
    device that is distinct from the
    protected internal storage and can be
    mounted as a filesystem on a computer.
    In devices with multiple “external”
    storage directories (such as both
    secure app storage and mountable
    shared storage), this directory
    represents the “primary” external
    storage that the user will interact
    with.

    I have not personally seen a case but there is no requirement that getExternalStorageDirectory returns the memory card. You are doing the correct thing by treating the returned directory as shared storage as it was an intentional decision by the device manufacturer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android app which uses camera. I am using a socket connection
I was wondering if it was possible to have an android app which is
I have an android app for which i need to ensure that it has
I have written an android app which listens to the phone signal strength using
I'm planning Android app which extensively uses local DB. DB would contain approx 15
I currently have an app which is set to support Android 2.2 and have
I'm doing some Android development, and I much prefer Visual Studio, but I'll have
I have an app which displays a large amount of text for the user
I'm using eclipse, and I have two android projects which have different topics. And
I have a free android app that I want to now distribute as free

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.