0

Is is possible to read data (read-only) from some form of database file saved by the user, at a pre-determined location, on the SD card?

I'd like to allow users of my map app to download map tiles for offline use. It would be more convenient to store this as a single file, hence thinking a database would be best. The file is likely to be around 8+ GB in size containing 100,000's of PNG tile images. Users would be intructed to download this file from the web and save it to the SD card themself.

I assume SQLite would be the way to go if possible.

Any limitations anyone is aware of? I keep hitting limitations developing with Windows Phone (not being able to save to SD card from app, not being able to attach files to email tasks, etc.) so figured I'd ask before trying this time.

Gavin
  • 5,629
  • 7
  • 44
  • 86
  • At present I've not been able to find a solution to allow this. SQLite for Windows Phone SDK doesn't support ExternalStorageFile so can't be used to read from the SD card at this time. Perhaps there's a NoSql type implementation someone knows about that supports ExternalStorageFile. – Gavin Dec 13 '13 at 20:04

2 Answers2

0

Yes, you can use so called "file type association" on Windows Phone 8 by defining specific file suffix that your app can open. You can than open any file (readonly!) either from phone, SD card or even email attachment. I guess once you read the file, you can copy it to apps IsolatedStorage for accessing is safely later.
See this for more details:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206987(v=vs.105).aspx

Martin Suchan
  • 10,600
  • 3
  • 36
  • 66
  • Good to know, but not the most elegant solution as I don't want to open any *.sqlite or *.db3 files with my app. But I guess I could register an extension called *.my_app so users don't end up trying to open any old database with my app. Size of the DB file is unlikely to be happy in IsolatedStrorage, but I see where you're coming on. Thanks for the feedback, I'll give it a go! – Gavin Nov 09 '13 at 00:19
  • I've checked that page and it should be possible to register *.sqlite and *.db3 file types for your app as well. And there is no memory cap for content in IsolatedStorage, you are only limited by the memory available in your phone.. – Martin Suchan Nov 09 '13 at 09:06
  • Cheers Martin, but as mentioned in previous comment - I think it would be best to come up with my own file extension name so Windows Phone doesn't start allowing users to open any old *.sqlite or *.db3 files with my app. I'm assuming Windows Phone will present my app to users if they click on a file type that I have registered my app as being able to open = confusion for user I believe. – Gavin Nov 09 '13 at 20:57
  • You can register any file extension you want for your db files, except some reserved extensions named in the MSDN page. – Martin Suchan Nov 09 '13 at 21:22
  • I've not marked this answer as correct yet as I've not been able to confirm it's true unfortunately. If you can prove the answer feel free to try winning the bounty I've just added to another question outlining my issue - http://stackoverflow.com/questions/20324380/unable-to-retrieve-data-from-sqlite-db-on-sd-card-on-wp8 – Gavin Dec 06 '13 at 20:21
  • Seems existing SQLite for Windows Phone SDK doesn't support ExternalStorageFile so can't read from SD card. Perhaps there's another library out there that supports ExternalStorageFile. Maybe even some NoSql solution. – Gavin Dec 13 '13 at 20:06
0

At present it isn't possible / easy to use an existing DB solution for reading from the SD card...

Unfortunately no DB libraries I've come across implement an interface that accepts ExternalStorageDevice or a Stream (provided using ExternalStorageDevice.GetFileAsync()) as a source for the database. Most want a file path which is then used with standard System.IO methods, these are blocked from accessing SD cards by Windows Phone.

I've also tried to adapt adapting various libraries but there is a bug within Windows Phone itself where the stream returned from ExternalStorageDevice.GetFileAsync() does not Seek from the first part of the file correctly. See this question for more detail.

Community
  • 1
  • 1
Gavin
  • 5,629
  • 7
  • 44
  • 86