public class dbhelper extends sqliteopenhelper
@override//建立表,重寫抽象方法,當資料庫第一次被建立時會呼叫該方法,若資料庫已存在則不呼叫
public void oncreate(sqlitedatabase db)
@override//重寫抽象方法,onupgrade方法在資料庫版本公升級時會被呼叫
public void onupgrade(sqlitedatabase db, int oldversion, int newversion)
//查詢資料庫中的資料
public cursor select()
//查詢資料庫中的資料
public cursor select_history()
//刪除
public void delete(int id)
;//找到要刪除的目標
db.delete(table_name, where, wherevalue);
}//刪除
public void delete_history(int id)
;//找到要刪除的目標
db.delete(table_history, where, wherevalue);
}public long insert(book u)//u為準備要插入的資料
public long insert_history(history u)//u為準備要插入的資料
public cursor query_name(string name)
//修改
public void update_history(int id,history u)
;//找到修改的目標
contentvalues cv=new contentvalues();
//新的值
cv.put(history_name,u.getname());
cv.put(history_path,u.getpath());
cv.put(history_time,u.gettime());
db.update(table_history, cv, where, wherevalue);
}}
mysql資料庫 查詢模型 mysql之SQL模型
sql模型 sql mode 通過定義某些規定,限制使用者行為,並定義對應的處理機制。常見的模型 ansi 寬鬆模式,對插入資料進行校驗,如果不符合定義型別或長度,對資料型別調整或截斷儲存,報warning警告。traditional 嚴格模式,當向mysql資料庫插入資料時,進行資料的嚴格校驗,保...
Android資料庫之SQLite
在android作業系統中使用的是sqlite資料庫,我們借助sqliteopenhelper這個sqlitedatabase的工具類來建立資料庫。首先我們需要建立乙個 sqliteopenhelper的子類 class databasehelper extends sqliteopenhelper...
Android手機開發 SQLite資料庫
1.定義乙個類,方便儲存和獲取資料 package com.eoeandroid.sqlite import android.content.contentvalues import android.content.context import android.database.cursor imp...