package com.zhy.zhy_ormlite.db;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.zhy.zhy_ormlite.bean.Article;
import com.zhy.zhy_ormlite.bean.Student;
import com.zhy.zhy_ormlite.bean.User;
public class DatabaseHelper extends OrmLiteSqliteOpenHelper
{
private static final String TABLE_NAME = "sqlite-test.db";
private Map<String, Dao> daos = new HashMap<String, Dao>();
private DatabaseHelper(Context context)
{
super(context, TABLE_NAME, null, 4);
}
@Override
public void onCreate(SQLiteDatabase database,
ConnectionSource connectionSource)
{
try
{
TableUtils.createTable(connectionSource, User.class);
TableUtils.createTable(connectionSource, Article.class);
TableUtils.createTable(connectionSource, Student.class);
} catch (SQLException e)
{
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase database,
ConnectionSource connectionSource, int oldVersion, int newVersion)
{
try
{
TableUtils.dropTable(connectionSource, User.class, true);
TableUtils.dropTable(connectionSource, Article.class, true);
TableUtils.dropTable(connectionSource, Student.class, true);
onCreate(database, connectionSource);
ine="crayon-5812c27b027c3170769743-51">51
52
53
54
55
56
57
58
59
60