• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

write files

 
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic