This project is read-only.

Possible to open DB from SD card / ExternalStorageFile?

Dec 7, 2013 at 11:38 PM
It it possible to open a read-only database from the SD card using this project?

It looks like a SQLite file should be able to be opened from the SD card looking at this SD code example from Microsoft:

But does this project support access from the SD card?
Dec 8, 2013 at 2:24 PM
Yes it does - but as with other files on an sd card, you have to declare a file association for the extension of your database file, and it only suppirts read-only access.
I have a sample I will post on my blog shortly, but there's nothing tricky about it.


Dec 9, 2013 at 2:00 AM
Cheers Andy - I look forward to seeing the example. Very much appreciated!

I've been having some issues myself using a different SQLite wrapper...

Would be great if I could get sqlite-winrt to work for me, but my issues seem to suggest I'm having trouble opening a file from the SD card.
Dec 10, 2013 at 12:05 AM
Hi Andy,

Just in case it's relevant to your sample (if you haven't created it yet)...

From my investigations trying to get sqlite-net-wp8 to work for me, someone gave me the following feedback:

_Your app doesn't have direct access to the files on the SD card. It can't open them directly with file system API, but needs to use the ExternalStorageFile and ExternalStorageFolderinterfaces from Windows.Storage. To quote from Reading from the SD card on Windows Phone 8:
Windows Phone apps can read specific file types from the SD card using the Microsoft.Phone.Storage APIs.
I expect that the SQLite implementation for the phone tries to open the database using standard C file API rather than using the Storage objects and so requires that the database be in the Xap or isolated storage and cannot access a database on the SD card (this is definitely the case for SQLite for Windows Store apps).

In theory it would be possible to update SQLite to use Storage objects, but I suspect it would be a significant project to do so._

Full discussion can be found here:
Dec 11, 2013 at 4:44 PM


My blog post is up.

I had a project from months back that did it, but when I came to look at it, found that it used a modified wrapper that I hadn’t posted up to codeplex! Anyway, the modification has been rolled into the master and it all works now.

Details at

Dec 11, 2013 at 8:33 PM
Hi Andy,

Cheers for that - but reading through your blog post I highly suspect the same issues I experienced with sqlite-net-wp8 highlighted above are going to be present. It looks like you won't be using the ExternalStorageFile.OpenForReadAsync method behind the scenes to open the file, as this needs to happen in the "SQLite for Windows Phone" SDK you're wrapping? Instead you're just allowing a string file path to be provided instead of the Windows.Storage.StorageFile object previously required so from this I guess I'll encounter the same issues.

Towards the end of this forum thread are detailed my discoveries which highlight the errors I encountered trying to access the SD card:

At the moment I think it's a limitation of the underlying SQLite SDK that a simple wrapper won't be able to overcome :(

Dec 11, 2013 at 11:14 PM

Oops – the embarrassment.

You’re quite right. I fooled myself because my sample is dual purpose and allows you to switch between opening a file in the app package, and (I thought) off the SD Card. Trouble is, when I thought it was opening the one on the card, it was actually opening the one in ms-appx:/// . I’ll look some more, but from reading your post on the forums, looks like you’ve already done the research.


Dec 11, 2013 at 11:25 PM
No worries - easily mistake to make - I've been guilty of similar ;)