Here's a bit of a head scratcher: Building a new app with sqlite, set up a singleton to handle all database functions. Once information is entered, it uses a List added to from the database so a prefab of text fields can be populated on screen. If there is a better way to do this, please let me know.
From the main script:
public void GetOilChangeInfo()
{
DatabaseManager.Instance.SQLiteInit();
OilChangeList.Clear(); Clear the list
OilChangeList = DatabaseManager.Instance.GetOilChangeList(); Make the list from the database
Debug.Log("How many?" + OilChangeList.Count); //This is correct, I have four entries
for(int i=0; i<OilChangeList.Count; i++)
{
Debug.Log(OilChangeList[i]); //Shows up as 4 nulls
}
}
On the Manager Class:
public List<OilChange> GetOilChangeList()
{
Debug.Log("Function Calls!");
mConnection.Open();
mSQLString = "SELECT * FROM " + SQL_TABLE_OIL_CHANGES;
mCommand.CommandText = mSQLString;
mCommand.ExecuteNonQuery();
mReader = mCommand.ExecuteReader();
while (mReader.Read())
{
OilChangeList.Add(newOilChange(mReader.GetString(0),
mReader.GetString(1),
mReader.GetString(2),
mReader.GetString(3),
mReader.GetString(4),
mReader.GetString(5),
mReader.GetString(6),
mReader.GetString(7),
mReader.GetString(8)));
//Debug.Log(mReader.GetString(0) + mReader.GetString(1) + mReader.GetString(2) + mReader.GetString(3) + mReader.GetString(4) + mReader.GetString(5) + mReader.GetString(6) + mReader.GetString(7) + mReader.GetString(8));
}
mReader.Close();
mConnection.Close();
return OilChangeList;
}
This gives an odd error, which may be the source of the problem
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed.
I have both scripts inheriting from monobehavior. This warning shows up after each entry. Anyone able to help me work this out? Thanks!