package
com.db.imgfornote;
import
android.content.ContentValues;
android.content.Context;
android.database.Cursor;
android.util.Log;
final
private
static
String mDbName=
"imgfornote"
;
static
int
mDbVersion=
1
;
static
DBHelper mInstance=
null
;
String mTUserPhoto=
"UserPhoto"
;
String mCreatesqlForNoteClass=
"create table if not exists NoteClass(classId integer primary key asc autoincrement,className NVARCHAR(100),rowTime timestamp default (datetime('now','localtime')))"
;
String mCreatesqlForUserPhoto=
"create table if not exists UserPhoto(photoId integer primary key asc autoincrement,photoName VARCHAR(200),userPt VARCHAR(200),title VARCHAR(255),classId integer,content NVARCHAR(250),tag NVARCHAR(200),remark text,status integer default 0,182)!important; background:none!important">;
String[] mInsertsqlForNoteClass={
"insert into NoteClass(className) values('默认分类[私有]');"
,
"insert into NoteClass(className) values('读书笔记[私有]');"
"insert into NoteClass(className) values('电子资料[公开]');"
};
private
DBHelper(Context context,CursorFactory factory) {
super
(context,mDbName,factory,mDbVersion);
}
DBHelper GetInstance(Context context,sqliteDatabase.CursorFactory factory)
{
if
(mInstance==
){
mInstance =
new
DBHelper(context,factory);
}
return
mInstance;
}
@Override
void
onCreate(sqliteDatabase db) {
// 创建表
//初始化数据
}
@Override
onUpgrade(sqliteDatabase db,
oldVersion,182)!important; background:none!important">newVersion) {
// TODO Auto-generated method stub
}
sqliteDatabase db =getWritableDatabase();
Log.i(
"ExecsqlForCursor"
sql);
db.rawQuery(sql,selectionArgs);
}
try
{
sqliteDatabase db =getWritableDatabase();
}
catch
(Exception e){
Log.e(
"Execsql Exception"
e.printStackTrace();
}
}
{
"Execsql"
sql);
(Exception e){
e.printStackTrace();
}
}
//添加照片信息
long
InsertUserPhoto(String photoName,String title){
sqliteDatabase db =getWritableDatabase();
ContentValues cv =
ContentValues();
cv.put(
"photoName"
"title"
db.insert(mTUserPhoto,cv);
}
//查询照片信息
public
Cursor SearchPhoto(
row,String sort){
Cursor cur =
;
{
String ord = (sort==
|| sort.toLowerCase().startsWith(
"a"
))?
"asc"
:
"desc"
;
String[] args = {String.valueOf(row)};
(row>
){
else
{
args=
;
}
(Exception e) {
@H_404_416@cur =
;