标签:
SQLite操作类:
package com.example.administrator.myapplication; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class BookmarkSQLiteOpenHelper extends SQLiteOpenHelper{ public BookmarkSQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){ super(context,name,factory,version); } @Override public void onCreate(SQLiteDatabase db){ String sql="create table bookmark(id integer primary key autoincrement,favicon varchar(100),title varchar(100),url varchar(100))"; db.execSQL(sql); } @Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){} }
SQLite初始化:
bookmarkSQLiteOpenHelper=new BookmarkSQLiteOpenHelper(this,"browser.db",null,1);
SQLite插入数据:
void insertBookmark(Bookmark bookmark){ SQLiteDatabase db=bookmarkSQLiteOpenHelper.getWritableDatabase(); db.execSQL("insert into bookmark(favicon,title,url)values(?,?,?)",new String[]{bookmark.getFavicon(),bookmark.getTitle(),bookmark.getUrl()}); }
标签:
原文地址:http://www.cnblogs.com/zqxLonely/p/5462549.html