1. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

App access to sdcard while in Eclipse debug?

Discussion in 'Android General Discussions' started by chasmopolitan, Sep 16, 2010.

  1. chasmopolitan
    Offline

    chasmopolitan New Member

    Joined:
    Sep 7, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Eagle, Idaho
    I would like my app to be able to open a file on the sdcard at:
    /sdcard//SmartRotor/ExampleZlog.txt

    The following method:

    public StreamProcessor()
    {
    System.out.println(filePath);
    try {
    fileReader = new FileReader( filePath );
    } catch (FileNotFoundException e) {
    System.err.println(e);
    }
    bufferedSmartRotorStream = new BufferedReader( fileReader );
    }

    displays logcat entries:

    INFO/System.out(28609): /sdcard//SmartRotor/ExampleZlog.txt
    WARN/System.err(28609): java.io.FileNotFoundException: /sdcard/SmartRotor/ExampleZlog.txt

    I notice when the DroidX is attached via the USB cable the Android Files manage cannot access the sdcard (probably owing to its being mounted on the laptop). I assume that is the reason I can't open the file from the app.

    Is there some incantation I'm missing that would permit
    fileReader = new FileReader( filePath );
    to an /sdcard/-based file path?

    Newbie,
    -chas-
  2. mwhartman
    Offline

    mwhartman Super Moderator/RS Premium Member

    Joined:
    Jan 15, 2010
    Messages:
    10,739
    Likes Received:
    12
    Trophy Points:
    38
    Location:
    South FL
    Most of the code you supplied is above my pay grade. I have a rooted Droid and when connected to my computer the SD card can only be accessed via the computer.

    Mike
  3. chasmopolitan
    Offline

    chasmopolitan New Member

    Joined:
    Sep 7, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Eagle, Idaho
    Thanks, Mike. I think that confirms my suspicions that the Eclipse USB-mount makes /sdcard inaccessible from the device. Unless there's some other Linux-like incantation by which the /sdcard can be shared and mounted by both the local and the remote. I guess I'll have to live with that restriction for now.

    You wouldn't by any change know how to create an /sdcard location for an Android Virtual Device(VD)?

    -chas-
  4. mwhartman
    Offline

    mwhartman Super Moderator/RS Premium Member

    Joined:
    Jan 15, 2010
    Messages:
    10,739
    Likes Received:
    12
    Trophy Points:
    38
    Location:
    South FL
    Sorry, I do not know how to configure.

    Mike
  5. chasmopolitan
    Offline

    chasmopolitan New Member

    Joined:
    Sep 7, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Eagle, Idaho
    Add directory structure and files to emulator /sdcard

    For posterity, here's what worked for me:

    On Windows Vista; fire up a command window (I have a desktop shortcut "%SystemRoot%\system32\cmd.exe")
    cd "C:\Program Files\android-sdk-windows\tools"
    mksdcard -l DroidXcard 500M C:\Users\<user>\.android\avd\Android7.avd\sdcard_v7
    Run Eclipse and open project. Then:
    Run -> Debug Configurations...->Android Application->"Target"<tab>
    You may have to resize the "Debug Configurations" window by dragging the lower border down to expose the "Additional Emulator Command Line Options" field.(!) Enter the file path to the sdcard image:
    -sdcard "C:\Users\<user>\.android\avd\Android7.avd\sdcard_v7"
    Within Eclipse, Run debug (F11), and go the DDMS view (tab labeled "DDMS" in upper right-hand corner of Eclipse window). In that view find the "File Explorer"<tab> which should show an \sdcard directory. *And* you should be able to enter the directory. If you can't you haven't properly created or loaded the mksdcard image. Note: You'll get cryptic "permission"-related messages.

    Terminate Eclipse debug session (<cntl>+F2). This leaves the AVD/emulator running and disconnects Eclipse from it.

    Again, from a command window in Windows Vista:
    cd C:\Program Files\android-sdk-windows\tools
    adb -e shell -- fires up a shell on the emulator
    cd sdcard -- puts you in the main directory of the sdcard image you created with mksdcard
    mkdir <myProjectDir> -- use to create any directory structure you need
    exit -- leave the shell
    Run Eclipse again and open project. Run debug (F11), and go the DDMS view. Using the Eclipse DDMS "File Explorer"<tab>, descend to the directory in /sdcard you want. In the upper right-hand corner of the "File Explorer"<tab> find icons for "Pull a file"... and "Push a file".... Use the latter to move a file from your Windows file system into the emulator's \sdcard file space.

    There may be better ways, but for this newbie, it worked.
    -chas-

    P.S. Why go to such lengths when you have a real DroidX? Because when you connect your device via USB, Windows auto-mounts the \sdcard directory depriving your device-resident app of access... <grumble>.
Search tags for this page
android debug sdcard shared
,

android eclipse access sd card

,
android real device debug sdcard mound
,
android sd card debug
,
cannot open file mt /sd card android wjile debug
,

como debugar app no sdcard

,
eclipse android phone sdcard access
,
eclipse can't access sd while debugging
,
eclipse sdcard
,
how to access sdcard in appstudio
,
how to access sdcard in eclipse
,
how to debug sd card
,
how to raed data from sd card in android eclipse
,
i can add file to sdcard in ddms in windows 7
,
motorola droid 3 cannot access sdcard ddms