What directory would be best to store the .SDF file in?


  • I am creating some applications for Windows Mobile 5.0 devices to be used internally at our company. Each device will run several home grown applications that will all share the same common SQL Mobile database.

    What I am wondering is whether or not there is a standard path where such a database is typically stored in Windows Mobile 5.0. I see a folder called Application Data. Is that what it is for, or is that one for something else? I'm not real familiar with the layout of the Pocket PC in general. Could someone tell me where vendors normally put their database file(s)?



    Friday, January 13, 2006 7:27 PM


  • Brad,

    This is one of those straight-forward questions with an involved answer -

    In the simplest case, you have a Windows Mobile app and an associated SQL CE or SQL Mobile database.  If this is the only app using the database, you can store that database in the program folder of the app (a typical thing to do), but if the device is hard-reset or the backup battery dies, you risk losing this database.  So the next thought is to place your database on non-volatile storage, meaning either a CF/SD card -or- in the file store that most manufacturers include as a partition in their file system images.  But then someone notices that database access is slower with the .SDF file on a storage card.  So there is a tradeoff between safety and performance.  If the database is going to be shared by more than one application, there is indeed a Databases folder on Windows Mobile, but this contains the 'object store' database files that provide persistence for the applications included in Windows Mobile.  It is not typical to place SDF files here, but there is nothing preventing you from doing so.  It is more typical to place a shared SDF file in the device root, in \My Documents\Business or in \My Documents\Personal.  This is not driven by any Microsoft standards, but rather by convention.

    So you can really choose where you want to put the file, but do factor in the use of non-volatile storage if there is anything mission-critical in your database.


    Monday, January 16, 2006 3:20 PM