SQLDroid Android平台的SQLite驱动

程序名称:SQLDroid

授权协议: EPL

操作系统: Android

开发语言: Java

SQLDroid 介绍

SQLDroid 是 Android 平台上的 SQLite 数据库的 JDBC
驱动程序。

示例代码:

// your datapath is /data/data/$package/
// e.g. “/data/data/com.lemadi.robotanks.android”

// note that if you want to put it in $datapath/databases/
// the way Activity.openOrCreateDatabase does it,
// you have to create the databases subfolder if not already there

String url = “jdbc:sqldroid:” + getDataPath() + “/main.sqlite”;
Connection con = DriverManager.getConnection(url);

con.createStatement().execute(“CREATE TABLE MYTABLE (id INT, name
CHAR(200))”);

try {
con.createStatement().execute(“CREATE TABLE MYTABLE (id INT, name
CHAR(200))”);
con.createStatement().execute(“CREATE TABLE HIGH_SCORES (level VARCHAR, name
CHAR, time INT, timestamp INT)”);
} catch (SQLException e1) {
System.out.println(“error creating table: i guess they were already there”);
}

con.createStatement().execute(“INSERT INTO MYTABLE (id, name) VALUES (100,
‘klm’)”);

PreparedStatement ps = con.prepareStatement(“INSERT INTO MYTABLE (id, name)
VALUES (?, ?)”);

ps.setInt(1, (int)(Math.random() * 100));
ps.setString(2, “you’re ” + new Integer((int)(Math.random()*1000)).toString()
+ ” years old.”);
ps.executeUpdate();

ResultSet rs = con.createStatement().executeQuery(“SELECT id, name FROM
MYTABLE ORDER BY name”);

while(rs.next()) {
System.out.println(“test row: ” + rs.getInt(1) + ” = ” + rs.getString(2));
System.out.println(“test row string: ” + rs.getInt(“id”) + ” = ” +
rs.getString(“name”));
}

rs.close();

// this method demonstrates the limited Metadata functionality:

private static boolean tableExists(String tableName) {
ResultSet rs = con.getMetaData().getTables(null, null, tableName, null);
// rs.next() returns true is there is 1 or more rows
return rs.next();
}

SQLDroid 官网

http://code.google.com/p/sqldroid/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


BBGestureBack Full screen return gesture(全屏手势返回 滑动返回 pop 动画效果) iOS 侧滑返回
Framework7 或者叫 F7 是全功能的绑定 iOS 7 应用的 HTML 框架。Framework7 是免费开源的 HTML
iOS 调试库,支持 iOS8+,无需添加任何代码,方便 iOS 开发和测试。 屏幕截图 使用教程
DarkModeKit是在Apple官方的深色模式发布之前设计和开发的。 它提供了一种机制来支持iOS 11+(包括iOS 13)上的应用程序的暗模式。
SimpleNote iOS 版客户端。SimpleNote 是一款在多平台上发布的笔记应用。 开发准备条件:
Kivy iOS,此工具旨在为 iOS 编译必要的库以运行应用程序并管理 Xcode 项目的创建。
TYDownloadManager是一个iOS的文件下载管理器包,可以提示下载过程中的最新进展和状态的变化。
mruby是一款轻量级的Ruby实现,遵循ISO标准。它可以以解释的形式或者在VM上编译和执行形式运行。
因为涉嫌危害消费者的隐私问题,苹果公司决定停止使用原有的UDID系统,移动应用软件开发者们正在竞相寻找新的替代方案。移动应用销售平台Appsfire目前推出了OpenUDID,它是一个开源版本的UDID。Appsfire声称他们已
EasyIOS 开源至今已经1周年,全新Swift版本今日发布,支持利用HTML来开发IOS应用,支持模拟器实时预览,基于MVVM思想,HTML数据绑定,反射所有
在 iOS 领域使用 Pod 来进行组件化开发时常常需要手动进行一系列的操作,来实现Pod 组件的更新目的。特别是一些业务关联性比较强的 Pod
PokerCard,一款 iOS 多样式弹窗开源库。 Basic Usage import PokerCard class ViewController: UIViewController {
MiaowShow MiaowShow是高仿《喵播APP》的iOS视频直播项目。 项目具体讲解地址 iOS视频直播初窥:高仿<喵播APP>
ZJAttributedText 是高性能轻量级富文本框架 前言 如果遇到上面一个需求, 你会怎么处理, 若干个 UILabel + UIImageView? NSAttributedString拼接? CoreText?
DynamicCocoa,是滴滴 App 架构组自研的 iOS 动态化方案,可以让现有的 Objective-C 代码转换生成中间代码(JS),下发后动态执行。滴滴客户端 App 架构团队表示正在积极准备相关事项,计划于 2017 年初开源。
ObjectiveSupport aims to bring some of the popular Rubyisms found in ActiveSupport to Objective-C. This project originated as a component of
StyleKit 是能让你使用一个简单的 JSON 文件美化你的应用的微框架。 它如何工作?
XCActionBar 是一个用于 Xcoded 的通用生产工具。
Social Go是一个基于iOS平台,在人群中获取小精灵的雷达和匿名聊天App。它使用Swift
Swift版本最新发布 : https://github.com/EasyIOS/EasyIOS- Swift 全新基于MVVM(Model-View-ViewModel)编程模式架构,开启EasyIOS开发函数式编程新篇章。