Skip to content

rizasif/sqlite-unity-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlite-unity-plugin

This plugin can be used to access sqlite database for unity projects in android and iOS devices.

Copy paste the Plugins folder in the Assets folder of your project (or copy paste the contents into your existsing Plugins folder) and follow the points below to access your database in c#.

  1. Import the correct namespaces.
using UnityEngine;
using System.Data;
using Mono.Data.Sqlite;
using System.IO;
  1. Open your database connection; if the database name (My_Database) does not exist it will be created.
string connection = "URI=file:" + Application.persistentDataPath + "/" + "My_Database";
IDbConnection dbcon = new SqliteConnection(connection);
dbcon.Open();
  1. Finally create a query to access your database.
IDbCommand dbcmd;
IDataReader reader;

dbcmd = dbcon.CreateCommand();
string q_createTable = 
  "CREATE TABLE IF NOT EXISTS " + "my_table" + " (" +
  "id" + " INTEGER PRIMARY KEY, " +
  "val" + " INTEGER )";
  
dbcmd.CommandText = q_createTable;
reader = dbcmd.ExecuteReader();

Sample

A Unity implementation of this plugin can be found here.

Tutorial

Read this artcle on medium for more details.

About

SQLite plugin for Unity3D Android and iOS build

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published