Android第二十五天

一:正则表达式 (regex)
    正则表达式描述了匹配的模式。
    1.经常使用匹配模式:
      \\ 匹配反斜线
      \d 匹配数字      \D 匹配非数字
      \w 匹配字母、数字、下划线
      ^  匹配行的开始
      $  匹配行的结尾
      .  匹配除了"."字符自己以外的全部字符
      \n 匹配换行
      [0-9]  匹配某个数字
      [a-z]  匹配小写字母
    2.经常使用匹配数量
      ? 匹配0次或1次 
      + 匹配1次或1次以上(至少1次)
      * 匹配任意次
      {n} 匹配n次
      {n,} 匹配至少n次
    3.匹配逻辑
      |  匹配“或”逻辑
      &  匹配“与”逻辑
   Java经常使用的正则工具类:
      Pattern类
      正则表达式的编译表示形式。
      public static Pattern compile(String regex) 将给定的正则表达式编译到模式中。正则表达式

      public Matcher matcher(CharSequence input) 建立匹配器sql

      Matcher类 (匹配器)
      public boolean matches() 执行匹配,若是匹配成功,返回true.数据库

   String类支持正则的方法:
   1.public String[] split(String regex) 根据给定正则表达式的匹配拆分此字符串。
   2.public boolean matches(String regex) 告知此字符串是否匹配给定的正则表达式。
   3.public String replaceAll(String regex,String replacement)
     使用给定的replacement替换此字符串全部匹配给定的正则表达式的子字符串。工具

二:SQLite数据库管理系统
    SQLite是一种小型的、轻量级、零配置的关系型数据库,常嵌入于便携式设备(eg:手机);url

    sqlite3  数据库文件名   打开或建立数据库文件sqlite

    SQLite的“点命令”:
    .database 显示数据库文件
    .table  查看表
    .schema 表名称   查看某表的结构(建表语句)
    .exit  退出SQLite环境
    .mode column 开启列模式
    .header on 显示表头 对象

    经常使用SQL语句:
    1.建表语句
        create table 表名称(
           主键字段  数据类型   primary key [autoincrement],
           字段2     数据类型   约束 (eg: not null),
           ...
         );
    2.插入数据
      insert into 表名称(字段1,字段2....)values(值1,值2,...);
    3.查询数据
      select 字段1,字段2,... from 表名称 [where 字段名 操做符 字段值 and xxx] [order by 字段名]
    4.修改数据
      update 表名称 set 字段名1=值1,字段名2=值2... [where 字段名 操做符 字段值 and xxx]
    5.删除数据
      delete from 表名称 [where  字段名 操做符 字段值 and xxx]
    6.删除表
      drop table 表名称;
    7.增长列
      alter table 表名称 add column 字段名 数据类型  约束;rem

三:JDBC(JavaDatabase Connection)
    1.DriverManager 驱动管理类
      public static Connection getConnection(String url) 试图创建到给定数据库URL的链接
    2.Connection 数据库链接类
      PreparedStatement prepareStatement(String sql)
    3.PreparedStatement  表示预编译的SQL语句的对象。
      setString(int parameterIndex,String x)
      setInt(int parameterIndex,int x)
      setXXX(xxx)
      int executeUpdate() 执行增、删、改的操做。
      ResultSet executeQuery() 执行查询,返回结果集
    4.ResultSet 查询结果集
      boolean next() 
      将光标下移,若是新的当前行有效,则返回 true;若是不存在下一行,则返回 false
      String getString(String columnLabel)字符串

相关文章
相关标签/搜索