Question

Can I use sqlite in windows phone 8.1 project on VS2013?

I am developing some windows phone 8.1 app with the WP8.1 SDK. https://dev.windowsphone.com/en-us/downloadsdk But I cannot use sqlite at all. I cannot find sqilte extension on the vs2013 extensions. ( VS2013 > TOOLS > Extensions and Updates > Online ) Is it not prepared yet?

I used sqilte very well in my W8 tablet project on vs2012. So I think that I can use same manner. http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/03/12/using-the-sqlite-database-engine-with-windows-phone-8-apps.aspx

Was it helpful?

Solution

Sqlite for Windows Phone 8.1 is officially released now:

http://visualstudiogallery.msdn.microsoft.com/5d97faf6-39e3-4048-a0bc-adde2af75d1b

OTHER TIPS

Yes, you can use SQLite in a Windows Phone App (non SL) 8.1 project. There isn't an official build yet for the driver. More info here. I think there will also need to be a version of the C++/CX wrapper as well, I'm not 100% sure about this though. That lives here. Once the drivers are available they should show up in Visual Studio Extensions the same way they do currently for Windows Phone 8.

update: Using SDK/library references in Universal Windows Apps

Local Databases are suported using LINQ to SQL. sqlCE reference databases can be deployed with your app.

more information can be found below for local databases in windows phone

Local Databses

Reference Databases

@Michael

I write some sample codes as you guided. Adding the System.Data.Linnq.dll refrence was works well and the builds well too.
But on running my app the InvalidProgramException was happend. I think that the WP8.0 and WP8.1 are differ each other very much.

This is exception call stack...

{System.InvalidProgramException: Common Language Runtime detected an invalid program.
at System.Data.Linq.DataContext..ctor(String fileOrConnection)
at KakaoTalk.Tests.LocoChatLogDataContext..ctor(String connectionString)
at KakaoTalk.Tests.SqlCeTestPage.OnNavigatedTo(NavigationEventArgs e)}

This is my sample codes...

public sealed partial class SqlCeTestPage : Page
{
    public SqlCeTestPage()
    {
        this.InitializeComponent();
    }

    /// <summary>
    /// Invoked when this page is about to be displayed in a Frame.
    /// </summary>
    /// <param name="e">Event data that describes how this page was reached.
    /// This parameter is typically used to configure the page.</param>
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        var dbCtx = new LocoChatLogDataContext("isostore:/locochatlog.sdf");

        if (dbCtx.DatabaseExists() == true)
        {
            dbCtx.DeleteDatabase();
        }

        dbCtx.CreateDatabase();
    }
}

public class LocoChatLogDataContext : DataContext
{
    // Pass the connection string to the base class.
    public LocoChatLogDataContext(string connectionString) : base(connectionString) { }

    // Specify a single table for the to-do items.
    public Table<LocoChatLog> Items;
}

[Table]
public class LocoChatLog : INotifyPropertyChanged
{
    #region long logId PropertyChanged
    long _logId;
    [Column(IsPrimaryKey = true)]
    public long logId
    {
        get
        {
            return _logId;
        }
        set
        {
            if (_logId != value)
            {
                _logId = value;
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(STR_logId));
                }
            }
        }
    }
    public const string STR_logId = "logId";
    #endregion

    public event PropertyChangedEventHandler PropertyChanged;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top