Giter Club home page Giter Club logo

Comments (2)

venetasoft avatar venetasoft commented on July 17, 2024

Does it work on Linux too..?

from sqliteforunity.

Brogni avatar Brogni commented on July 17, 2024

A little late, but I may have an answer. Maybe it can be useful for future users.

The problem is that the example copies the 'default' database (located in StreamingAssets) in the new location on the phone, but that database was crated in the Editor mode and it may be not read correctly on mobile devices, especially if it is encrypted.

The solution is to directly create a new database in the new position. I show a piece of my code:

private ISQLiteConnection _connection;
private DatabaseController()
{
    // We check the existance of the database. If it does not exists we create a new one.
    var factory = new ConnectionFactory();
// check if file exists in Application.persistentDataPath
filepath = string.Format("{0}/{1}", Application.persistentDataPath, DatabaseName);
if (!File.Exists(filepath))
{
        // Creating new database
        Debug.Log("Database not in Persistent path: creating new one");
        _connection = factory.Create(filepath);
        CreateScoreTable();
        LockDB();
        Debug.Log("Database written in " + filepath);
    }
    else { 
        dbPath = filepath;
        firstCreation = false;
        _connection = factory.Create(dbPath);
    }
    Debug.Log("Database succesfully load");
}

/// <summary>
/// Creating the score table. Method to use when we have created a new database.
/// </summary>
public void CreateScoreTable()
{
    _connection.CreateTable<YourTable>();
}

/// <summary>
/// Encripts the database
/// </summary>
public void LockDB()
{
    _connection.SetDbKey(Password);
}`

from sqliteforunity.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.