首先实现便签功能,密码箱、待办记录稍后完成。
便签表设计:
表名:note
字段:_id,title,content,create_time(建立时间),visiable(是否显示,1是,0否)
SQL:create table note( _id integer primary key autoincrement,title text,content text,ctime text,visiable integer)
NoteColumn代码:
package chenzx.dataassistant.db;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
/**
* 便签类。用于定义建立note表及其它与nota表有关的操作
* @author chenzx
*
*/
public class NoteColumn extends DatabaseColumn {
public static final String TABLE_NAME="note";
public static final String TITLE="title";
public static final String CONTENT="content";
public static final String VISIABLE="visiable";
public static final String CREATE_TIME="create_time";
/**
* 表Uri
*/
public static final Uri CONTENT_URI =Uri.parse("content://" + AUTHORITY + "/" + TABLE_NAME);
/**
* 表结构
*/
private static final Map
mColumnMap = new HashMap
();
/**
* 表结构生成
*/
static {
mColumnMap.put(_ID, "integer primary key autoincrement");
mColumnMap.put(TITLE, "text not null");
mColumnMap.put(CONTENT, "text not null");
mColumnMap.put(VISIABLE, "integer not null");
mColumnMap.put(CREATE_TIME, "localtime");
}
/**
* @retrun 表名
*/
@Override
public String getTableName() {
// TODO Auto-generated method stub
return TABLE_NAME;
}
/**
* @return 返回建表uri
*/
@Override
public Uri getTableContent() {
// TODO Auto-generated method stub
return CONTENT_URI;
}
/**
* @return 返回表结构映射
*/
@Override
protected Map
getTableMap() {
// TODO Auto-generated method stub
return mColumnMap;
}
}