0

I am trying to connect SQLite DB file to my unity project where db file is present in downloads folder but I am unable to get data from tables. How can I connect download folder contain DB file to unity project SQLite. My requirement is able to run a project with downloaded db file which is present in the downloads folder. Please suggest any idea. Thanks in advance. Here is the code I am using for connecting db file to SQLite.

Sample code :

        Debug.Log("Call to OpenDB:" + databaseName);

        var tempdbPath = Path.GetFullPath("log -29-10-2018 - .db");

        var tempdbbytes = File.ReadAllBytes(tempdbPath);

        var _filePath = tempdbPath;

        ApplicationContext.CurrentDatabasePath = _filePath;

        //open db connection
        _connectionString = "URI=file:" + _filePath;

(where _filePaht = /Users/deepak/Projects/testproject/test/log -29-10-2018 - .db)

        ApplicationContext.TempConnectionString = _filePath;

        ApplicationContext.ConnectionString = _connectionString;

        Debug.Log("Stablishing connection to: " + _connectionString);

        dbcon = new SqliteConnection(_connectionString);

        dbcon.Open();
    }
    catch (Exception exception)
    {
        LoggingManager.Error(exception);
    }
}

When I connect persistence folder contain db file it's working well, I am getting a problem when I am trying to connect db file present in the downloads folder.

Deepak
  • 545
  • 1
  • 12
  • 36
  • I've seen this exact question this week but believe that you didn't get an answer because it's not clear enough. *"When I connect persistence folder contain db file it's working well, I am getting a problem when I am trying to connect db file present in the downloads folder"* .... Please explain this. What do you mean by persistence folder? What do you mean by downloads folder? – Programmer Oct 31 '18 at 04:39
  • persistence folder means => If I created db file in using below formate ,data is retrieved from tables well _filePath = Application.persistentDataPath.PersistanceDataPath + "/" + databaseName; – Deepak Oct 31 '18 at 04:47
  • In my project one of the feature is user able to export or send his db file to another person. So what I am trying to do is Insted of creating new db file dowloaded the user sent db file and try to connect that db file. Here user sent db file is present in download folder in my system. – Deepak Oct 31 '18 at 04:50
  • You said the file is in the download folder. Use the Download path? `C:\Users\\Downloads\Investigation` or just read [this](https://stackoverflow.com/questions/10667012/getting-downloads-folder-in-c) post for how to get the path of the Download folder. – Programmer Oct 31 '18 at 12:08
  • @Programmer => Can you please look this post now you will get clear idea => https://stackoverflow.com/questions/53077096/how-to-connect-sqlite-db-to-unity – Deepak Oct 31 '18 at 13:03

0 Answers0