SQLite Android Bindings

Check-in [71a3449ef6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update CustomSqlite.java to call "SELECT sqlite_version()".
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 71a3449ef6c12645b7a35486d12d9a0f1af7449f
User & Date: dan 2013-12-18 17:36:15.023
Context
2013-12-18
18:04
Add a dummy version (equivalent to BINARY) of collation sequence LOCALIZED to all new database handles. Now a simple "SELECT sqlite_version()" works. (check-in: 87449ff921 user: dan tags: trunk)
17:36
Update CustomSqlite.java to call "SELECT sqlite_version()". (check-in: 71a3449ef6 user: dan tags: trunk)
17:23
Commit the various hacks to android files made outside of fossil. (check-in: 7e57f15de2 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to res/layout/main.xml.
1
2
3
4
5
6

7
8
9
10
11













12
13
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Hello World, CustomSqlite"
    />













</LinearLayout>







>





>
>
>
>
>
>
>
>
>
>
>
>
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Hello World, CustomSqlite"
    />
<TextView
    android:id="@+id/tv_widget"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="this text should be replaced by the sqlite version"
    />

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Find SQLite version"
        android:onClick="find_version"
        />
</LinearLayout>

Changes to src/org/sqlite/app/customsqlite/CustomSqlite.java.

1
2
3
4











5
6
7
8
9
10
11
12
13
14



























15

package org.sqlite.app.customsqlite;

import android.app.Activity;
import android.os.Bundle;












public class CustomSqlite extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }



























}
>




>
>
>
>
>
>
>
>
>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

package org.sqlite.app.customsqlite;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import org.sqlite.database.sqlite.SQLiteDatabase;
import org.sqlite.database.sqlite.SQLiteStatement;

/*
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
*/

public class CustomSqlite extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void find_version(View view){

      System.loadLibrary("sqliteX");

      SQLiteDatabase db = null;
      SQLiteStatement st;
      String res;

      TextView tv = (TextView)findViewById(R.id.tv_widget);
      tv.setText("<attempting to access sqlite...>");

      try {
        db = SQLiteDatabase.openOrCreateDatabase(":memory:", null);
        st = db.compileStatement("SELECT sqlite_version()");
        res = st.simpleQueryForString();

        tv.setText(res);
            
      }catch(Exception e){
        Log.e("Error", "Error", e);
        tv.setText(e.toString());
      } finally {
        if (db != null)
          db.close();
      }
    }
}