Are you using a sqlite plugin? If yes, then everything is quite simple:
When you connect a database, you create a connection to it and hash it:
private SQLiteConnection _connection; _connection = new SQLiteConnection(dbPath, SQLiteOpenFlags.ReadWrite);
dbPath - path to the base, including its name. The second parameter is the type of connection. In the database you have the so-called Table - tables with specific columns. Create in unity a class with the same parameters as in the desired table. For example, if you need only a parameter and its value:
using SQLite4Unity3d; public class PARAMS { [PrimaryKey, AutoIncrement, NotNull] public string PARAM { get; set; } [NotNull] public int VALUE{ get; set; } public override string ToString() { return string.Format ( "[mess: Param= {0}, " + "value: {1}.]", PARAM , VALUE ); } }
To add to DB, the following call is made:
public void InsertParam(string param, int value) { var p = new PARAMS { PARAM = param, VALUE = value }; _connection.Insert(p); }
Accordingly, as they said a little higher, if the application closes urgently, then void OnApplicationQuit () {} will not work. Therefore, it is best to save the value immediately after it changes.