Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Copy sqlite db from resource folder to Application.persistentDataPath (iOS/Android)

Discussion in 'Scripting' started by timothykc, Oct 22, 2021.

  1. timothykc

    timothykc

    Joined:
    Aug 25, 2017
    Posts:
    2
    I've lost a few days on this and can't seem to find the pattern I need across other posts...

    Keeping it simple: inside of editor folder "Assets/Resources/mySqlite_db"

    When I stay within the editor, something basic like this works fine:

    Code (CSharp):
    1.  
    2. string assetPath = "Assets/Resources/" + mySqlite_db;
    3. string dataPath = Application.persistentDataPath + "/" + mySqlite_db;
    4. File.Copy(assetPath, dataPath);
    5.  
    When I run my app on iOS/Xcode, the database fails to copy to the persistent path on the iOS device.

    I'm hoping someone can explain the correct way to load and then copy my Db from the Resources Folder over to the Device's persistent folder.

    If Resources folder is not the correct place to start, I'm flexible. Just stuck at the moment so thank you for your time in advance.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520