| 1 | <HTML> |
| 2 | <BODY> |
| 3 | Contains the SQLite database management |
| 4 | classes that an application would use to manage its own private database. |
| 5 | <p> |
| 6 | Applications use these classes to manage private databases. If creating a |
| 7 | content provider, you will probably have to use these classes to create and |
| 8 | manage your own database to store content. See <a |
| 9 | href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> |
| 10 | to learn the conventions for implementing a content provider. If you are working |
| 11 | with data sent to you by a provider, you do not use these SQLite classes, but |
| 12 | instead use the generic {@link android.database} classes. |
| 13 | |
| 14 | <p>The Android SDK and Android emulators both include the |
| 15 | <a href="{@docRoot}studio/command-line/sqlite3.html">sqlite3</a> command-line |
| 16 | database tool. On your development machine, run the tool from the |
| 17 | <code>platform-tools/</code> folder of your SDK. On the emulator, run the tool |
| 18 | with adb shell, for example, <code>adb -e shell sqlite3</code>. |
| 19 | |
| 20 | <p>The version of SQLite depends on the version of Android. See the following table: |
| 21 | <table style="width:auto;"> |
| 22 | <tr><th>Android API</th><th>SQLite Version</th></tr> |
| 23 | <tr><td>API 31</td><td>3.32</td></tr> |
| 24 | <tr><td>API 30</td><td>3.28</td></tr> |
| 25 | <tr><td>API 28</td><td>3.22</td></tr> |
| 26 | <tr><td>API 27</td><td>3.19</td></tr> |
| 27 | <tr><td>API 26</td><td>3.18</td></tr> |
| 28 | <tr><td>API 24</td><td>3.9</td></tr> |
| 29 | <tr><td>API 21</td><td>3.8</td></tr> |
| 30 | <tr><td>API 11</td><td>3.7</td></tr> |
| 31 | <tr><td>API 8</td><td>3.6</td></tr> |
| 32 | <tr><td>API 3</td><td>3.5</td></tr> |
| 33 | <tr><td>API 1</td><td>3.4</td></tr> |
| 34 | </table> |
| 35 | |
| 36 | <p>Some device manufacturers include different versions of SQLite on their devices. |
| 37 | There are two ways to programmatically determine the version number. |
| 38 | |
| 39 | <ul> |
| 40 | <li>If available, use the sqlite3 tool, for example: |
| 41 | <code>adb -e shell sqlite3 --version</code>.</li> |
| 42 | <li>Create and query an in-memory database as shown in the following code sample: |
| 43 | <pre> |
| 44 | String query = "select sqlite_version() AS sqlite_version"; |
| 45 | SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(":memory:", null); |
| 46 | Cursor cursor = db.rawQuery(query, null); |
| 47 | String sqliteVersion = ""; |
| 48 | if (cursor.moveToNext()) { |
| 49 | sqliteVersion = cursor.getString(0); |
| 50 | }</pre> |
| 51 | </li> |
| 52 | </ul> |
| 53 | </BODY> |
| 54 | </HTML> |