0

Problem 1: When we creat a sqlite database with sqlite IDE or coding we don’t define sqlite version(1/2/3). So what is the default version and which version we use automatically?

Problem 2: Is there any way to get my current and old sqlite database file version by java coding or something else?

Thanks in advance.

Xplosive
  • 711
  • 3
  • 14
  • 26
  • 1
    Regarding your first question http://stackoverflow.com/questions/2421189/version-of-sqlite-used-in-android – Random Feb 11 '14 at 20:59
  • 1
    It's almost certain that you're on some 3.x version (seeing as it came out ten years ago). Also relevant: [How to find SQLITE database file version](http://stackoverflow.com/questions/9646353/how-to-find-sqlite-database-file-version) – rutter Feb 11 '14 at 21:01
  • 1
    first problem is clear to me. But I don't konw how to use magic header and this type of command. $ file file2.db file2.db: SQLite 2.x database $ file file3.db file3.db: SQLite 3.x database @rutter – Xplosive Feb 11 '14 at 21:13
  • [`file`](http://unixhelp.ed.ac.uk/CGI/man-cgi?file) is a Unix command. As far as the header, you can check the first 16 bytes of the file: if they are equal to the string `SQLite format 3`, you are apparently dealing with a SQLite 3.x database file. [SQLite's documentation describes their file header in some detail](http://sqlite.org/fileformat.html). – rutter Feb 11 '14 at 22:41
  • 1
    Thanks for your reply. I got it. Can you help me about second question. @rutter – Xplosive Feb 12 '14 at 05:35
  • By database version, do you really mean the sqlite engine version i.e. 3 really for android-sqlite, or the schema version you use e.g. when calling `SQLiteOpenHelper` super constructor? – laalto Feb 12 '14 at 07:19
  • Now I want to know schema version. @laalto – Xplosive Feb 12 '14 at 08:55

1 Answers1

1
  1. Android sqlite is sqlite3. The specific version depends on the device and software version.

  2. You can get your schema version with SQLiteDatabase getVersion() in Java code or PRAGMA user_version in SQL.

Community
  • 1
  • 1
laalto
  • 150,114
  • 66
  • 286
  • 303