提交 e98c67c8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Android API support (work in progress).

上级 c4bbfa8f
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
*/
package android.net;
/**
* TODO
*/
public class Uri {
// empty
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
*/
package android.os;
/**
* TODO
*/
public class Bundle {
// empty
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains classes that are needed to compile the H2 Android database API.
</p></body></html>
\ No newline at end of file
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
*/
package android.test;
import org.h2.android.H2Database;
import org.h2.android.H2Utils;
import android.app.Activity;
import android.database.Cursor;
/**
* Tests the Android API.
*/
public class Test extends Activity {
public static void main(String... args) throws Exception {
H2Database db = H2Utils.openOrCreateDatabase("helloWorld.db", MODE_PRIVATE, null);
log("opened ps=" + db.getPageSize());
try {
// db.execSQL("DROP TABLE IF EXISTS test");
// log("dropped");
db.execSQL("CREATE TABLE if not exists test(ID INTEGER PRIMARY KEY, NAME VARCHAR)");
log("created");
for (int j = 0; j < 10; j++) {
Cursor c = db.rawQuery("select * from test", new String[0]);
int count = c.getCount();
for (int i = 0; i < count; i++) {
c.move(1);
c.getInt(0);
c.getString(1);
}
c.close();
}
// log("select " + count);
db.execSQL("delete from test");
log("delete");
db.beginTransaction();
for (int i = 0; i < 1000; i++) {
db.execSQL("INSERT INTO TEST VALUES(?, 'Hello')", new Object[] { i });
}
db.setTransactionSuccessful();
db.endTransaction();
log("inserted");
for (int i = 0; i < 10; i++) {
Cursor c = db.rawQuery("select * from test where id=?", new String[] { "" + i });
int count = c.getCount();
if (count > 0) {
c.move(1);
c.getInt(0);
c.getString(1);
}
c.close();
}
log("select");
} finally {
db.close();
log("closed");
}
}
private static void log(String s) {
System.out.println(s);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Javadoc package documentation
</title></head><body style="font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font-weight: normal;"><p>
This package contains tests.
</p></body></html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论