android sqlite dsl ANGROM

码农软件 · 软件分类 · 手机开发包 · 2019-05-06 10:59:30

软件介绍

ANGROM 是一个简单的android 数据库 dsl, 解决了数据库版本控制问题, 提供了select查询类.

使用入门

  1. 下载并导入jar包

  2. 创建MyApplication类

public class MyApplication extends Application {

  @Override
  public void onCreate() {
      super.onCreate();

  }}
  1. 修改 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="xx.xx.xx"
  android:versionCode="1"
  android:versionName="1.0" >

  <application
      android:name=".MyApplication"
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >

  </application></manifest>
  1. 创建数据库

public class MyApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    MigrationManager migrationManager = new MigrationManager();
    Migration user = new CreateTable("users")
               .addAutoIncrementPrimaryKey("id")
               .addColumn(Genre.STRING, "name");
    migrationManager.addMigration(1, user); // 添加数据库1的迁移, 可以添加很多个
    SQLHelper sqlHelper = new SQLHelper(getContext(), migrationManager, "test.db", 1);
    sqlHelper.getWritableDatabase();
  }}

5.修改版本

public class MyApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    MigrationManager migrationManager = new MigrationManager();
    Migration user = new CreateTable("users")
               .addAutoIncrementPrimaryKey("id")
               .addColumn(Genre.STRING, "name");
    migrationManager.addMigration(1, user); // 添加数据库1的迁移, 可以添加很多个

    Migration person = new CreateTable("person")
                .addAutoIncrementPrimaryKey("id")
                .addColumn(Genre.STRING, "age");
    migrationManager.addMigration(2, person);

    Migration test1 = new CreateTable("test1")
            .addAutoIncrementPrimaryKey("id")
            .addColumn(Genre.INTEGER, "age");
    migrationManager.addMigration(3, test1);

    Migration test2 = new CreateTable("test2")
            .addAutoIncrementPrimaryKey("id")
            .addColumn(Genre.INTEGER, "age");
    migrationManager.addMigration(4, test2);

    SQLHelper sqlHelper = new SQLHelper(getContext(), migrationManager, "test.db", 4);
    sqlHelper.getWritableDatabase();
  }}
  1. 使用查询

Cursor cursor = new Select("id, name")
                .from("users")
                .where(String.format("id=%s", id_.toString()))
                .query(sqlHelper.getReadableDatabase());if (cursor.moveToNext()) {
    Assert.assertEquals(cursor.getString(1), "ngdkSelect");} else {
    Assert.fail("测试失败");}Cursor cursor = new Select("id, name")
                .from("users")
                .where("id=?")
                .query(sqlHelper.getReadableDatabase(), new String[] {id.toString()});if (cursor.moveToNext()) {
    Assert.assertEquals(cursor.getString(1), "ngdkSelect");} else {
    Assert.fail("测试失败");}

本文地址:https://codercto.com/soft/d/5136.html

构建高性能Web站点

构建高性能Web站点

郭欣 / 电子工业出版社 / 2012-6 / 75.00元

《构建高性能Web站点(修订版)》是畅销修订版,围绕如何构建高性能Web站点,从多个方面、多个角度进行了全面的阐述,几乎涵盖了Web站点性能优化的所有内容,包括数据的网络传输、服务器并发处理能力、动态网页缓存、动态网页静态化、应用层数据缓存、分布式缓存、Web服务器缓存、反向代理缓存、脚本解释速度、页面组件分离、浏览器本地缓存、浏览器并发请求、文件的分发、数据库I/O优化、数据库访问、数据库分布式......一起来看看 《构建高性能Web站点》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具