Storing PDFs to load?

CRoscoeCRoscoe CAMember ✭✭

This feels like a silly question, but here it goes.

Our app will end up downloading PDFs (And other attachments). To open it I tried making a webview, which failed and gave me tons of errors. I then decided to go native and wrote some Android/iOS code to open up the PDF on the targets themselves.

What happened is I got an error on both platforms saying they couldn't find my filepath. This lead me to google where to store resources (I've been doing in in the Resource folder with images). From my googling it seems that you can call images by filename instead of path name, but not other file types?

I guess my question is, where SHOULD I be storing .pdf's and other files that are not images if I plan to call upon them and view them while the app is running?

This seems so basic but when I googled it I couldn't find a good answer.

Posts

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    in the forum there are codes to open pdf and other docs in Android and iOS.
    I use https://msdn.microsoft.com/it-it/library/system.io.path.gettemppath(v=vs.110).aspx

  • CRoscoeCRoscoe CAMember ✭✭

    Sorry but that does not help me. Xamarin Studio is saying Path.GetTempPath() does not exist, and running through what does exist in this context of Path had lead me to learn nothing.

    I just want to know where I should store files that are not images in Xamarin, and what is the path name for when I want to access it.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Sorry, you have talk about "download " and I have thought you would download files from the web.

    in this article http://developer.xamarin.com/guides/cross-platform/application_fundamentals/data/part_5_using_data_in_an_app/
    you can see how to deploy a sqlite db with your package (apk, ipa...)
    you can use the same approach to deploy another type of file

  • CRoscoeCRoscoe CAMember ✭✭

    I know you can use an SQLite database, and I will be using one at a later date with the app. I just wanted to know how to reference files stored in the resource folder in Xamarin forms so that I can test that my PDFViewer is actually working without having to set up an entire database.

    I guess I'll just put off testing it until we're at the point in development where the database is coming into play, and just test it then.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Sorry again Carson.
    I have post that link because you can use your pdf document as the SQLite described in the link.
    In Android, for example, you can add the PDF to Assets, then, with a code like that used to "copy" the SQLite db from Assets to a directory, you can copy your pdf from assets to a directory.

    I hope to have been clear

Sign In or Register to comment.