Android Community
Results 1 to 4 of 4

Thread: Emulator & Windowns: Has anyone been able to read files or directories?

  1. #1
    Join Date
    Feb 2009
    Posts
    19

    Default Emulator & Windowns: Has anyone been able to read files or directories?


    Hello again.

    Another newbie question for the long suffering experts here...

    I'm running the Android emulator with eclipse under WinXP.

    I have the following code:

    Code:
    File filePath = new File( "file.txt");
    String fileName = filePath.getName();
    try {
      BufferedReader input =  new BufferedReader(new FileReader(fileName));
    }
    catch( FileNotFoundException e1 ) {
      System.out.println("Error: File not found");
    }
    This throws the exception FileNotFoundException.

    Under Linux this would be easy, but how to correctly specify file paths under Windows? I've copied the file to all directories:

    • the windows C: root directory
    • the eclipse project root directory
    • the eclipse project src directory
    • the eclipse project bin directory

    and it cannot find the file. Can anyone help?

    Thanks,
    Paul

  2. #2
    Join Date
    Sep 2008
    Location
    The Boonies of Pinal County, Arizona
    Posts
    1,186

    Default Re: Emulator & Windowns: Has anyone been able to read files or directories?

    You need to push it to the emulator/dev phone. Think of the emulator as its own OS running in its own sandbox much like Parallels or VMware allows you to run MS-Windows from within Linux.

    Check the DDMS perspective in Eclipse for an easy GUI wrapper around 'adb'. I forget the directory you want to push it to offhand, I think it's "/data/app-data/your.namespace/".

  3. #3
    Join Date
    Feb 2009
    Posts
    19

    Default Re: Emulator & Windowns: Has anyone been able to read files or directories?

    ickyfehmleh,

    Many thanks again.

    That worked. I copied the file to /data/app-private, and specified this explicit path as follows:
    Code:
    String fileName = "file.txt";
    String dirName = "/data/app-private";
    File filePath = new File( dirName, fileName);
    Paul

  4. #4
    Join Date
    Sep 2008
    Location
    The Boonies of Pinal County, Arizona
    Posts
    1,186

    Default Re: Emulator & Windowns: Has anyone been able to read files or directories?


    There are methods on Context that will return the proper directory name. Future releases of Android may move /data/app-private/ to something entirely different, so it's important to use the proper API and not hardcode directories.

Similar Threads

  1. iPhone Emulator
    By ubercode in forum Developers Guild
    Replies: 24
    Last Post: 12-27-2011, 04:46 AM
  2. Nes emulator!!!
    By cevatt11 in forum All About Andorid Software
    Replies: 33
    Last Post: 05-31-2009, 02:44 PM
  3. any chance of something that will read "reader" files .lit
    By BillDoor in forum Developers Guild
    Replies: 4
    Last Post: 03-12-2009, 02:08 PM
  4. G1 Emulator Is Out.
    By jayclip in forum General Phone Chat
    Replies: 1
    Last Post: 10-21-2008, 08:04 AM
  5. G1 Emulator
    By GrimShadows in forum General Phone Chat
    Replies: 1
    Last Post: 10-10-2008, 12:12 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •