title: How do I populate a ListView with data from a SQLite database
body: <p>I am building a cross platform mobile application with Xamarin forms. The problem I am stuck on right now is this: I have a page that I want to display the information from a database in a <code>ListView</code> on the page. Also there are two tables in the sqlite database.</p>
  
  <ol>
  <li><p>First I created an override of the <code>OnAppearing</code> method for the page so that the data would show up once the page appears. </p></li>
  <li><p>Then inside that I opened up an sqlite connect like so </p>
  
  <pre><code>using(SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation))
  {
    //about to put the code here in the next step
  }
  </code></pre></li>
  <li><p>Then inside that I tried to create the table from the database like so (and by 'ModelName' I mean the name of class that holds the model that aligns with the data in the sqlite database)</p>
  
  <pre><code>conn.CreateTable&lt;ModelName&gt;
  </code></pre></li>
  <li><p>and then tried to use a query and then set that as the ItemSource for the ListView like so </p>
  
  <pre><code>ListViewName.ItemSource = conn.Query&lt;ModelName&gt;("SELECT * FROM databaseTableName;");
  </code></pre></li>
  <li><p>On the front end I've set the data binding like this. </p>
  
  <pre><code>&lt;ListView x:Name="ListViewName"&gt;
      &lt;ListView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextCell Text="{Binding ModelName}" Detail="{Binding ModelName}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListView.ItemTemplate&gt;
  &lt;/ListView&gt;
  </code></pre></li>
  </ol>
  
  <p>Note: I've also tried setting the binding like this </p>
  
  <pre><code>Text="{Binding ColumnNameFromTable}"
  </code></pre>
  
  <p>when I run it I get an error message that says that the table doesn't exist but I have the sqlite database in the project (in assets folder of the android project and in the resources folder of the iOS project) 
  And the table is there. So I don't know where I am going wrong </p>
  
  <p>Also to answer the question about what </p>
  
  <pre><code>(App.DatabaseLocation)
  </code></pre>
  
  <p>is set to the following in the MainActivity.cs and AppDelegate.cs respectively </p>
  
  <pre><code>//in MainActivity.cs
  string dbName = "DatabaseName.db";
  string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
  string fullPath = Path.Combine(folderPath, dbName);
  LoadApplication(new App(fullPath));
  </code></pre>
  
  <pre><code>//in AppDelegate.cs
  string dbName = "DatabaseName.db";
  string folderPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),"..", "Library");
  string fullPath = Path.Combine(folderPath, dbName);
  LoadApplication(new App(fullPath));
  </code></pre>
  
  <p>I appreciate any and all help anyone wiser than I could provide. Thank you for taking the time to read and maybe answer my question. I owe you my undying gratitude!</p>