title: Inserting Data into SQLite Database Using C#
body: <p>I am creating an <code>SQLite</code> Database in <code>Visual Studio</code> with <code>Xamarin</code> in <code>C#</code>.</p>
  
  <p>I should note that this is for <code>android</code> only.</p>
  
  <p>I am trying to make it so I am able to insert data into the <code>SQLite</code> database but I am unsure how.</p>
  
  <p>I have been following <a href="http://developer.xamarin.com/guides/cross-platform/application_fundamentals/data/part_3_using_sqlite_orm/" rel="nofollow">this</a> but I'm still unsure.</p>
  
  <p>Here is the method I am trying to create.</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Insert a single ping group into the SQLite ping database.
      /// &lt;/summary&gt;
      /// &lt;param name="pingGroup"&gt;&lt;/param&gt;
      public void AddUnsynchronizedPing(PingGroup pingGroup)
      {
          // TODO: Add the passed ping group parameter into the SQLite database as new/unsynchronized.
          if (pingGroup != null)
          {
              // Add ping group to the database.
              // Add pings to the database.
              // Maybe one step, maybe done separately.
              // If done separately, must set Ping.PingGroupID to ID of original ping group.
          }
      }
  </code></pre>
  
  <p>For context, here is the entire class.</p>
  
  <pre><code>namespace BB.Mobile
  {
  /// &lt;summary&gt;
  /// A class to provide a single interface for interacting with all SQLite data operations for stored tracking points.
  /// &lt;/summary&gt;
  /// 
  class DataManager
  {
      private SQLiteConnection db = null;
  
      public DataManager()
      {
          if (this.db == null)
          {
              string dbPath = Path.Combine(
               System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
               "bb.db3");
  
              db = new SQLiteConnection(dbPath);
              db.CreateTable&lt;Ping&gt;();
              db.CreateTable&lt;PingGroup&gt;();
          }
      }
  
      /// &lt;summary&gt;
      /// Will compile and return all matching unsynchronized ping data from the SQLite database.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public List&lt;PingGroup&gt; GetUnsynchronizedPings()
      {
          List&lt;PingGroup&gt; unsynchronizedPings = new List&lt;PingGroup&gt;();
  
          // TODO: Retrieve all unsynchronized pings from the SQLite database and return them to the caller.
          //var pGroup = db.Get&lt;PingGroup&gt;();
          //var pGroupList = db.List&lt;PingGroup&gt;();
  
          var pGroups = db.Table&lt;PingGroup&gt;();
          foreach (var pGroup in pGroups)
          {
  
          }
  
          return unsynchronizedPings;
      }
  
      /// &lt;summary&gt;
      /// Insert a single ping group into the SQLite ping database.
      /// &lt;/summary&gt;
      /// &lt;param name="pingGroup"&gt;&lt;/param&gt;
      public void AddUnsynchronizedPing(PingGroup pingGroup)
      {
          // TODO: Add the passed ping group parameter into the SQLite database as new/unsynchronized.
          if (pingGroup != null)
          {
              // Add ping group to the database.
              // Add pings to the database.
              // Maybe one step, maybe done separately.
              // If done separately, must set Ping.PingGroupID to ID of original ping group.
          }
      }
  
      /// &lt;summary&gt;
      /// Mark all open and unsynchronized pings in the database as synchronized.
      /// &lt;/summary&gt;
      public void SetAllPingsSynchronized()
      {
          db.DeleteAll&lt;PingGroup&gt;();
          db.DeleteAll&lt;Ping&gt;();
      }        
  }
  }
  </code></pre>
  
  <p>Thank you in advance.</p>