• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

write files

 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning,
i am a little confused on the concept of reading/writing files to an android device. Firstly i get a byte[] object from a web service, i want to save it to a file with name.doc, if it is a doc file, i know what file i am getting each time from the web service. Were do i save this file so i can then open it from an intent to wordtogo fror example? if the device does not have a sdcard were do i save it. i use this code below for saving the file to data/data/apk name/files but when it executes the open file commands it says permission denied.



thanks in advance guys..
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help please? i can see that the files are created in the directory /data/data/package/files/ but when i try to open them adobe reader or/and word to go displays a message 'permission denies'. is there a fallback to save files that can be opened through other apps(adobe reader) from my app?

thanks again.
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I recall correctly, files stored in the apps data directory are accessible by that app only. You would have to store the file in a globally accessible location, such as on an SD card, to enable other apps to read it.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what uri do i use to save to sdcard? is it like /sdcard/myfile.pdf ? and what if the device doesnt have an sdcard? where can i save the files so i can then open them with adobe reader within my appplication.
thanks again.
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The uri is usually /mnt/sdcard/...
Hopefully you have already read this documentation, because you should be using the getExternalFilesDir() method:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic