Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to read file from Emulator's SD  RSS feed

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()

 
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have this permission in your manifest:

 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes ...

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

Still not working....
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishal Trivedi wrote:not working


Which means what, exactly? Logcat output, please.
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
We can walk to school together. And we can both read this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!