I am new to Xamarin Forms and Xamarin in general. I may be misunderstanding how the architecture works, or I may be following a mix of different examples online. I am trying to use as much of the Portable Class Library as possible.
My nuget packages are Xamarin.Forms and SQLite.Net-PCL. They are installed on all, Droid, ios, windows, and PCL. Definitely the most recent verified highest downloaded. I am following these guides
https://developer.xamarin.com/guides/xamarin-forms/working-with/databases/
On the SQLite_Droid implementation of the SQLite interface, I do not have access to the Xamarin.Forms using statement or the one that has the Interface, Here is all the code in the Native_PCL Project.
ISQLite.cs
using SQLite.Net;
namespace Native_PCL.DataServices
{
interface ISQLite
{
SQLiteConnection GetConnection();
}
}
DataCalls.cs
using System.Linq;
using SQLite.Net;
using Xamarin.Forms;
using Native_PCL.Data;
namespace Native_PCL.DataServices
{
public class DataCalls
{
static object locker = new object();
SQLiteConnection db;
public DataCalls()
{
db = DependencyService.Get<ISQLite>().GetConnection();
db.CreateTable<UserPreferences>();
db.CreateTable<Orders>();
}
public void SubmitData(Orders order, out string update)
{
lock (locker)
{
if (!db.Table<Orders>().Any(x => x.foodName == order.foodName))
{
db.Insert(order);
update = order.foodName;
}
else { update = order.foodName + " was already in your Order"; }
}
}
}
}
Here is all the code in the Native_PCL.Droid project
SQLite_Droid.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content; // for some reason all of the System. and Android. are showing white. Usually unused statements are grayed out!
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Native_PCL;
using Native_PCL. ; /// only .Droid is registering
using Xamarin.Forms; //Intellisense does not pick this up
namespace Native_PCL.Droid.DataImplement
{
public class SQLite_Droid : Native_PCL.DataServices.ISQLite /// All white, Doesn't register the ISQLite as an Interface.
{
}
}
I have recreated the entire project. I must be doing something completely wrong.