Introduction

Player Prefs Plus is a replacement system for the standard Unity Player Prefs functionality.
It provides many enhancements to the standard system, amongs others these include multi-player support and a wide range of data types.

Please use the online version of the SQL4Unity documentation for more information
about supported data types and using the SQL4Unity database

Steve Smith 2018.


Installation

Please read the file Assets/SSSoftware/PlayerPrefsPlus/ReadMe before using Player Prefs Plus.

Using Player Prefs Plus

Player Prefs Plus consists of 3 run-time C# scripts, 1 Unity Editor C# script and an SQL4Unity Database.

Editor Script
PlayerPrefsEditor.cs - The Unity Editor GUI script for editing players, preferences and preference values via the editor.

Run-time Scripts
PlayerPrefsSetup.cs - Script containing the code for setting up players and preferences
PlayerPrefsPlus.cs - Script for run-time manipulation of preference values for a player.
PlayerPrefsSQL.cs - Script containing the SQL statements to save and retrieve the data in the database.

Database
PlayerPrefsPlus.s4u



Player Prefs Editor

To start Player Prefs Plus in the Unity Editor go to Tools->Player Prefs Plus->Editor
The editor implements most of the functions that are available via the three run-time scripts.
The database comes initially with a 'Default Values' player and three example preferences defined. These may be deleted if you do not with to use them


Open a player by clicking on the triangle next to the players name. To Close a player click on the triangle again.
Opening a player will display a new window showing that players preferences and values.


To create a player press on the 'New Player' button.
A window will open when you can enter the players name.
Press 'Save' to create the player.
Press 'New Player' button to close the window without saving.


To create a new preference press on the 'New Preference' button.
A window will open where you can enter the preference name and select the preference data type.
The name will be used as the preference 'key' in the run-time scripts and is case sensitive.
Refer to the SQL4Unity documentation for more information about data types.
Press 'Save' to create the preference.
Press 'New Preference' button to close the window without saving.


To add a preference to a player, open the player.
Select the preference from the drop down.


The preference will be added to the player and value(s) can now be added.


Enter the required value and press 'Add'.
Repeat the above if multiple values for the preference are required.


Press 'Save' to save the value(s) to the database.




To delete a value from a preference.
Select the preference value to be deleted.
Right click on the preference value
Select 'Delete Value'
Press 'Save' to delete the value from the database.


When a player is open each defined preference has an 'Options' button.
Pressing this button displays two menu options:-
'Delete Preference' - This will delete this preference and its values from the player.
'Delete Preference Value(s)' - This will delete this preference values for the player.


Pressing the 'Options' button for the player displays five menu options:-
'Refresh' - Redraw the players preference window.
'Delete Player' - Delete the player and his preferences from the database.
'Delete ALL Preferences' - Delete all of the preferences and values from the player.
'Delete ALL Preference Values' - Delete all of the preference values from the player.
'Set Default Preferences' - Copy all of the preferences and values from the 'Default Values' player to this player.


The player preference windows can be dragged in order to view the preferences and values of multiple players.


Player Prefs Setup

Constructor
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup()
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup(MonoBehaviour mono, Actiion<bool> callback
Note: You must use the the above constructor if targeting WebGL. Please refer to the secton on WebGL below

Methods
bool AddPlayer(string name)
Description
Add a new player to the database
Parameters
name The name of the player to add
Return values
true The player has been added to the database
false The player has not been added to the database Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.AddPlayer("John");
playerprefssetup.Close();

bool AddPref(string key, string dataType)
Description
Add a new preference to the database
Parameters
key The name of the preference
dataType The datatype of the preference
Datatype must be one of:- int, string, bool, float, long, byte, DateTime, Vector2, Vector3, Vector4, Color, Quaternion, Rect, Sprite, Resource, GameObject
Refer to the SQL4Unity documentation for more information on data types.
Return values
true The preference has been added to the database
false The preference has not been added to the database Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.AddPref("Health", "int");
playerprefssetup.Close();

void Close()
Description
Close database and release resources
Parameters
none
Return values
none
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
/* Do something here */
playerprefssetup.Close();

bool DeletePlayer(string name)
DeletePlayer(int playerID)
Description
Delete a player and his preferences from the database
Parameters
name The name of the player to delete
playerID The unique identifier of the player to delete
Return values
true The player has been deleted from the database
false The player has not been deleted from the database Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.DeletePlayer("John");
playerprefssetup.Close();

bool DeletePref(string key)
DeletePref(int prefID)
Description
Delete a preference and its values from the database
Parameters
key The name of the preference to delete
prefID The unique identifier of the preference to delete
Return values
true The preference has been deleted from the database
false The preference has not been deleted from the database Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.DeletePref("Health");
playerprefssetup.Close();

bool RenamePlayer(string oldName, string newName)
Description
Change the name of a player
Parameters
oldName The current name of the player
newName The new name for the player
Return values
true The player has been renamed
false The player has not been renamed Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.RenamePlayer("John","Fred");
playerprefssetup.Close();

bool RenamePref(string oldKey, string newKey)
Description
Change the name of a preference
Parameters
oldKey The current name of the preference
newKey The new name for the preference
Return values
true The preference has been renamed
false The preference has not been renamed Error message written to the console
Example
PlayerPrefsSetup playerprefssetup = new PlayerPrefsSetup();
playerprefssetup.RenamePref("Health","Strength");
playerprefssetup.Close();

Player Prefs Plus

Constructor
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus()
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus(string PlayerName)
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus(int PlayerID)
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus(MonoBehaviour mono)
Note: You must use the the above constructor if targeting WebGL. Please refer to the secton on WebGL below
Parameters
PlayerName The name of the player
If the player does not exist he will be created
PlayerID The unique identifier of the player
mono A valid MonoBehaviour
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");

Properties
string Name The name of the current player
int ID The unique identifier of the current player

Methods
void AutoSave(bool save)
Description
Turn automatic saving of changes on or off. Default is on.
Parameters
save If true changes will be automatically saved.
If false changes will not be saved until Save() is called
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.AutoSave(false);
playerprefsplus.Set("Health",10);
playerprefsplus.Set("Wisdom",20);
playerprefsplus.Save();
playerprefsplus.Close();

void Close()
Description
Close database and release resources
Parameters
none
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
/* Do something here */
playerprefsplus.Close();

bool DeleteAll()
Description
Delete ALL preferences and values from the player
Parameters
none
Return values
true All preferences and values for the player have been deleted
false The preferences and values have not been deleted Error message written to the console
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.DeleteAll();
playerprefsplus.Close();

bool DeleteAllValues()
Description
Delete ALL preference values from the player
Parameters
none
Return values
true All preference values for the player have been deleted
false The preference values have not been deleted Error message written to the console
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.DeleteAllValues();
playerprefsplus.Close();

bool DeleteKey(string key)
Description
Delete a specific preference and its values from the player
Parameters
key The name of the preference to be deleted from the player
Return values
true The preference and its values for the player have been deleted
false The preference and its values have not been deleted Error message written to the console
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.DeleteKey("Health");
playerprefsplus.Close();

Dictionary<string, object> Get()
Description
Retreive all preferences and their values for the player
Parameters
none
Return values
Dictionary<string, object> The dictionary will contain one entry per preference set for the player
The dictionary key is the preference name
The dictionary value can be cast to the data type defined for the preference.
If multiple values have been set for the preference the dictionary value will be an object[]
If a preference has no values set the dictionary value will be null;
null No Preferences found for the player
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
Dictionary<string,object> playerprefs = playerprefsplus.Get();
int health = (int)playerprefs["Health"];
playerprefsplus.Close();

object Get(string key)
Get(string key, int seq)
Description
Retreive a named preference value(s) for the player
Parameters
key The preference name
seq The sequence number of a preference value when multiple values have been defined
Return values
object The value can be cast to the data type defined for the preference.
If multiple values have been set for the preference the value will be an object[]
If a preference has no values set the value will be null;
null The named preference not found for the player
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
int health = (int)playerprefsplus.Get("Health");
playerprefsplus.Close();

void GetPlayerByID(int PlayerID)
Description
Retrieve a player by unique identifier
Parameters
PlayerID The unique identifier of the player to retrieve
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus();
playerprefsplus.GetPlayerByID(1); // 1 is the ID of the default values player
/* Do something here */
playerprefsplus.Close();

void GetPlayerByName(string PlayerName)
Description
Retrieve or Create a player
Parameters
PlayerName The name of the player to retrieve
If the player does not exist he will be created
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus();
playerprefsplus.GetPlayerByName("John");
/* Do something here */
playerprefsplus.Close();

int GetAllPlayers(out playerprefsplus_player[] Players)
Description
Retrieve all player details
Parameters
out playerprefsplus_player[] An array of player details
Return values
int The number of players found
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus();
playerprefsplus_player[] players;
int count = playerprefsplus.GetAllPlayers(out players);
/* Do something here */
playerprefsplus.Close();

int GetPlayerCount()
Description
Retrieve the number of players
Parameters
none
Return values
int The number of players found
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus();
int count = playerprefsplus.GetPlayerCount();
/* Do something here */
playerprefsplus.Close();

bool HasKey(string key)
Description
Checks if the player has a specified preference
Parameters
key The name of the preference to check
Return values
true The player does have this preference
false The player does not have this preference
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
int health = 0;
if (playerprefsplus.HasKey("Health") health = (int)playerprefsplus.Get("Health");
playerprefsplus.Close();

void OpenAsync(Action<bool> callback)
Description
Opens the database asyncronously. Must be used if targting WebGL
Parameters
callback A method in the form void Callback(bool ok) to call when the database is open
The parameter ok will contain true if the database opened and false if it did not.
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus(this); // Where this is a MonoBehaviour
playerprefsplus.OpenAsync(Callack);
return;

void CallBack(bool ok) {
   // Do somethng here
}

void Save()
Description
Saves any changes to the database. Use with AutoSave(false)
Parameters
none
Return values
none
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.AutoSave(false);
playerprefsplus.Set("Health",10);
playerprefsplus.Set("Wisdom",20);
playerprefsplus.Save();
playerprefsplus.Close();

bool Set(string key, string value)
Set(string key, string value, int seq)
Set(string key, string[] value)
Set(string key, int value)
Set(string key, int value, int seq)
Set(string key, int[] value)
Set(string key, bool value)
Set(string key, bool value, int seq)
Set(string key, bool[] value)
Set(string key, float value)
Set(string key, float value, int seq)
Set(string key, float[] value)
Set(string key, byte value)
Set(string key, byte value, int seq)
Set(string key, byte[] value)
Set(string key, long value)
Set(string key, long value, int seq)
Set(string key, long[] value)
Set(string key, DateTime value)
Set(string key, DateTime value, int seq)
Set(string key, DateTime[] value)
Set(string key, Vector2 value)
Set(string key, Vector2 value, int seq)
Set(string key, Vector2[] value)
Set(string key, Vector3 value)
Set(string key, Vector3 value, int seq)
Set(string key, Vector3[] value)
Set(string key, Vector4 value)
Set(string key, Vector4 value, int seq)
Set(string key, Vector4[] value)
Set(string key, Quaternion value)
Set(string key, Quaternion value, int seq)
Set(string key, Quaternion[] value)
Set(string key, Rect value)
Set(string key, Rect value, int seq)
Set(string key, Rect[] value)
Set(string key, Color value)
Set(string key, Color value, int seq)
Set(string key, Color[] value)
Set(string key, GameObject value)
Set(string key, GameObject value, int seq)
Set(string key, GameObject[] value)
Set(string key, Sprite value)
Set(string key, Sprite value, int seq)
Set(string key, Sprite[] value)
Set(string key, Object value)
Set(string key, Object value, int seq)
Set(string key, Object[] value)
Description
Set the value(s) of a preference for the player
Parameters
key The name of the preference to set
value The value or array of values to set for the preference.
The data type must match that defined for the preference
seq The sequence number of a value in an array to set. Sequence starts at zero
Return values
true The value(s) have been set
false The value(s) have not been set Error message written to the console
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
int health = 100;
int[] wisdom = new int[] { 10,20,30 };
playerprefsplus.Set("Health", health);
playerprefsplus.Set("Wisdom", wisdom);
playerprefsplus.Set("Wisdom", 25, 1); // Replace the value of 20 with 25
playerprefsplus.Close();

bool SetDefaults()
Description
Copies the default preferences and values to the current player
Parameters
none
Return values
true The default preferences have been copied
false The default preferences have not been copied Error message written to the console
Example
PlayerPrefsPlus playerprefsplus = new PlayerPrefsPlus("John");
playerprefsplus.SetDefaults();
playerprefsplus.Close();

Player Prefs SQL

Constructor
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL()
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL(MonoBehaviour mono)
Note: You must use the the above constructor if targeting WebGL. Please refer to the secton on WebGL below

Methods
void AutoSave(bool save)
Description
Turn automatic saving of changes on or off. Default is on.
Parameters
save If true changes will be automatically saved.
If false changes will not be saved until Save() is called
Return values
none
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.AutoSave(false);
playerprefssql.PlayerSet(1,"Health",10);
playerprefssql.PlayerSet(1,"Wisdom",20);
playerprefssql.Save();
playerprefssql.Close();

void Close()
Description
Close database and release resources
Parameters
none
Return values
none
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
/* Do something here */
playerprefssql.Close();

bool PlayerDeleteAll(int PlayerID)
Description
Delete ALL preferences and values from a player
Parameters
PlayerID The unique identifier of the player
Return values
true All preferences and values for the player have been deleted
false The preferences and values have not been deleted Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.PlayerDeleteAll(1);
playerprefssql.Close();

void OpenAsync(Action<bool> callback)
Description
Opens the database asyncronously. Must be used if targting WebGL
Parameters
callback A method in the form void Callback(bool ok) to call when the database is open
The parameter ok will contain true if the database opened and false if it did not.
Return values
none
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL(this); // Where this is a MonoBehaviour
playerprefssql.OpenAsync(Callack);
return;

void CallBack(bool ok) {
   // Do somethng here
}

bool PlayerDeleteAllValues(int PlayerID)
Description
Delete ALL preference values from a player
Parameters
PlayerID The unique identifier of the player
Return values
true All preference values for the player have been deleted
false The preference values have not been deleted Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.PlayerDeleteAllValues(1);
playerprefssql.Close();

bool PlayerDeleteKey(int PlayerID, string key)
Description
Delete a specific preference and its values from a player
Parameters
PlayerID The unique identifier of the player
key The name of the preference to be deleted from the player
Return values
true The preference and its values for the player have been deleted
false The preference and its values have not been deleted Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.PlayerDeleteKey(1, "Health");
playerprefssql.Close();

bool PlayerGet(int PlayerID, out Dictionary<string, object> values)
Description
Retreive all preferences and their values for the player
Parameters
PlayerID The unique identifier of the player
values The dictionary will contain one entry per preference set for the player
The dictionary key is the preference name
The dictionary value can be cast to the data type defined for the preference.
If multiple values have been set for the preference the dictionary value will be an object[]
If a preference has no values set the dictionary value will be null;
Return values
true The function completed sucessfully
false No Preferences found for the player
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
Dictionary<string,object> playerprefs; playerprefssql.PlayerGet(1, out playerprefs);
int health = (int)playerprefs["Health"];
playerprefssql.Close();

bool PlayerGet(int PlayerID, string key, out object value)
PlayerGet(int PlayerID, string key, int seq, out object value)
Description
Retreive a named preference value(s) for a player
Parameters
PlayerID The unique identifier of the player
key The preference name
seq The sequence number of a preference value when multiple values have been defined
value The value can be cast to the data type defined for the preference.
If multiple values have been set for the preference the value will be an object[]
If a preference has no values set the value will be null;
Return values
true A preference value was found
false The named preference not found for the player
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
int health = (int)playerprefssql.PlayerGet(1, "Health");
playerprefssql.Close();

string GetPlayerByID(int PlayerID)
Description
Retrieve a player by unique identifier
Parameters
PlayerID The unique identifier of the player to retrieve
Return values
string The name of the player found
If no player was found returns "UNKNOWN"
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
string name = playerprefssql.GetPlayerByID(1); // 1 is the ID of the default values player
/* Do something here */
playerprefssql.Close();

int GetPlayerByName(string PlayerName)
Description
Retrieve or Create a player
Parameters
PlayerName The name of the player to retrieve
If the player does not exist he will be created
Return values
int The unique identifier of the player
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
int playerID = playerprefssql.GetPlayerByName("John");
/* Do something here */
playerprefssql.Close();

int GetAllPlayers(out playerprefsplus_player[] Players)
Description
Retrieve all player details
Parameters
out playerprefsplus_player[] An array of player details
Return values
int The number of players found
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefsplus_player[] players;
int count = playerprefssql.GetAllPlayers(out players);
/* Do something here */
playerprefssql.Close();

int GetPlayerCount()
Description
Retrieve the number of players
Parameters
none
Return values
int The number of players found
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
int count = playerprefssql.GetPlayerCount();
/* Do something here */
playerprefssql.Close();

bool PlayerHasKey(int PlayerID, string key)
Description
Checks if a player has a specified preference
Parameters
PlayerID The unique identifier of the player to retrieve
key The name of the preference to check
Return values
true The player does have this preference
false The player does not have this preference
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
int health = 0;
if (playerprefssql.PlayerHasKey(1, "Health") health = (int)playerprefssql.PlayerGet(1, "Health");
playerprefssql.Close();

void Save()
Description
Saves any changes to the database. Use with AutoSave(false)
Parameters
none
Return values
none
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.AutoSave(false);
playerprefssql.PlayerSet(1, "Health", 10);
playerprefssql.PlayerSet(1, "Wisdom", 20);
playerprefssql.Save();
playerprefssql.Close();

bool PlayerSet(int PlayerID, string key, object value)
PlayerSet(int PlayerID, string key, object value, int seq)
PlayerSetArray(int PlayerID, string key, object value)
Description
Set the value(s) of a preference for the player
Parameters
PlayerID The unique identifier of the player to retrieve
key The name of the preference to set
value The value or array of values to set for the preference.
The data type must match that defined for the preference
seq The sequence number of a value in an array to set. Sequence starts at zero
Return values
true The value(s) have been set
false The value(s) have not been set Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
int health = 100;
int[] wisdom = new int[] { 10,20,30 };
// Set the preferences for Player with ID = 1 playerprefssql.PlayerSet(1,"Health", health);
playerprefssql.PlayerSetArray(1,"Wisdom", wisdom);
playerprefssql.PlayerSet(1,"Wisdom", 25, 1); // Replace the value of 20 with 25
playerprefssql.Close();

bool SetPlayerDefaults(int PlayerID)
Description
Copies the default preferences and values to the specified player
Parameters
PlayerID The unique identifier of the player
Return values
true The default preferences have been copied
false The default preferences have not been copied Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
// Set Default preferences for Player with ID = 2 playerprefssql.SetPlayerDefaults(2);
playerprefssql.Close();

bool CopyPlayerValues(int PlayerID, int CopyID)
Description
Copies the preferences and values from one player to another
Parameters
PlayerID The unique identifier of the player to copy to
CopyID The unique identifier of the player to copy from
Return values
true The preferences have been copied
false The preferences have not been copied Error message written to the console
Example
PlayerPrefsSQL playerprefssql = new PlayerPrefsSQL();
playerprefssql.CopyPlayerValues(2, 1);
playerprefssql.Close();

Player Prefs Plus Database

Below is the Player Prefs Plus database taken from the SQL4Unity Workbench.
The foreign key relationships are:-
Player.ID = PlayerPref.PlayerID
Pref.ID = PlayerPref.PrefID
PlayerPref.ID = PlayerPrefValue.PlayerPrefID. These can be sorted by Seq.








Targeting WebGL

When targeting WebGL the constructors of PlayerPrefsSetup, PlayerPrefsPlus and PlayrPrefsSQL must use the MonoBehaviour format.
The database can then be opened using the OpenAsync methods of PlayerPlusPlus and PlayerPrefsSQL (This is done automatically for PlayerPrefsSetup).
Once the callback from these methods has executed the database can then be used in the normal way.


            using System.Collections.Generic;
            using UnityEngine;

            public class OpenDB : MonoBehaviour
            {
                PlayerPrefsPlus playerPrefsPlus = null;

                void Start()
                {
                    playerPrefsPlus = new PlayerPrefsPlus(this);
                    playerPrefsPlus.OpenAsync(IsOpen);
                }

                void IsOpen(bool ok)
                {
                    if (ok)
                    {
                        playerPrefsPlus.GetPlayerByName("steve");
                        playerPrefsPlus.SetDefaults();
                        Dictionary<string, object> playerprefs = playerPrefsPlus.Get();
                        Debug.Log(playerprefs.Count + " preference values found");
                        foreach (KeyValuePair<string, object> kvp in playerprefs)
                        {
                            Debug.Log(kvp.Key + " " + kvp.Value.ToString());
                        }
                        playerPrefsPlus.Close();
                    }
                    else
                    {
                        Debug.Log("Database unavailable");
                    }
                }
            }
    

Note: Should you wish to access a database from another location using the file:///, http:// or https:// protocols this structure can also be used. Please refer to the SQL4Unity documenation for more information