*
The moose likes Android and the fly likes Unable to read file from Emulator's SD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Unable to read file from Emulator Watch "Unable to read file from Emulator New topic
Author

Unable to read file from Emulator's SD

Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
Hello

I havebeen trying to create and Read a file from SDCard however I am unable to read file.The wrting of file and reading is done in the same activity.And I have also made changes in AndroidManifest.

Please help me find my error and I know it has to be silly.
Here is my code




Every thing here seems ok except i m getting null value when i readLine()

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Do you have this permission in your manifest:



JBoss In Action
Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
Yes ...

I even tried using open[In/Out]putFile()....

Still not working....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
Vishal Trivedi wrote:not working

Which means what, exactly? Logcat output, please.


Ping & DNS - my free Android networking tools app
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Looking at your code, it looks like you forgot to close the file after writing it. The readline() won't find any content until the buffer is flushed, and closing the file will do that.
 
 
subject: Unable to read file from Emulator's SD