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

Sqlite for Android, help please

Discussion in 'Android' started by rambramdt, Jul 17, 2011.

  1. Graphitech

    Graphitech

    Joined:
    Sep 14, 2012
    Posts:
    10
    Thanks zenggangZg0, your libsqlite3.so fixed our problem!
     
  2. Helderth

    Helderth

    Joined:
    Dec 29, 2015
    Posts:
    6
    It works!!! Thank you!!!
     
  3. SpingDeveloper

    SpingDeveloper

    Joined:
    Nov 21, 2017
    Posts:
    13
    Sorry to bump up this old topic, but in Android 9.0 there seems to be an issue with libsqlite3. I'm using the SimpleSQL unity3d plugin to manage my database and there is a libsqlite3.so file added. It works fine on Android 8.1.0 and lower Android versions. But as soon as I open the app on an Android 9.0 device (Same installation e.t.c.) I get the following error:
    Code (CSharp):
    1. SQLiteException: database disk image is malformed
    2.       at SimpleSQL.SQLite3.Prepare2 (IntPtr db, System.String query) [0x00000] in <filename unknown>:0
    3.       at SimpleSQL.SQLiteCommand.Prepare () [0x00000] in <filename unknown>:0
    4.       at SimpleSQL.SQLiteCommand.ExecuteQuery[User] (SimpleSQL.TableMapping map) [0x00000] in <filename unknown>:0
    5.       at SimpleSQL.SQLiteCommand.ExecuteQuery[User] () [0x00000] in <filename unknown>:0
    6.       at SimpleSQL.TableQuery`1[User].GetEnumerator () [0x00000] in <filename unknown>:0
    7.       at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[User,User].MoveNext () [0x00000] in <filename unknown>:0
    8.       at System.Linq.Enumerable.First[User] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
    9.       at User.getUser (SimpleSQL.SimpleSQLManager dbManager) [0x00000] in <filename unknown>:0
    10.       at Translation.getLocalizationForKey (SimpleSQL.SimpleSQLManager dbManager, System.String key) [0x00000] in <filename unknown>:0
    11.       at PVMInstructionsSceneManager.setTranslations () [0x00000] in <fi
    Can it have something to do with with this change in Android 9.0?:

    Java UTF decoder
    UTF-8 is the default charset in Android. A UTF-8 byte sequence can be decoded by a String constructor, such as String(byte[] bytes).

    The UTF-8 decoder in Android 9 follows the Unicode standards more strictly than in previous versions. The changes include the following:

    • The non-shortest form of UTF-8, such as <C0, AF>, is treated as ill-formed.
    • The surrogate form of UTF-8, such as U+D800..U+DFFF, is treated as ill-formed.
    • The maximal subpart is replaced by a single U+FFFD. For example, in the byte sequence "41 C0 AF 41 F4 80 80 41," the maximal subparts are "C0," "AF," and "F4 80 80." "F4 80 80" can be the initial subsequence of "F4 80 80 80", but "C0" can't be the initial subsequence of any well-formed code unit sequence. Thus, the output should be "A\ufffd\ufffdA\ufffdA."
    • To decode a modified UTF-8 / CESU-8 sequence in Android 9 or higher, use the DataInputStream.readUTF()method or the NewStringUTF() JNI method.

     
  4. XiaodongLi

    XiaodongLi

    Joined:
    May 22, 2018
    Posts:
    2
    I have a question,please help me if you had the answer: i have a question :How use Sqlite on Android? I read the sqlite from StreamingAssets on the start and File.WriteAllBytes to persistentDataPath ,and then link the db. but i got the error:the database disk image is malformed ... please help me