Chinaunix首页 | 论坛 | 博客
  • 博客访问: 426784
  • 博文数量: 105
  • 博客积分: 1088
  • 博客等级: 中校
  • 技术积分: 1145
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-21 16:28
文章分类

全部博文(105)

文章存档

2012年(4)

2011年(39)

2010年(62)

分类: SQLite/嵌入式数据库

2011-10-09 16:28:43

public class DBAdapter
{
public static final String KEY_ROWID = "_id";
public static final String KEY_BOB = "bob";
public static final String KEY_X = "xx";
public static final String KEY_Y = "yy";
private static final String TAG = "xxx";
private static final String DATABASE_NAME = "sprite";
private static final String DATABASE_TABLE = "bob";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_CREATE =
               "create table "+DATABASE_TABLE +
               "(_id integer primary key autoincrement,"+
               "bob  text not null,"+
               "xx float not null,"+
               "yy float not null);";
private final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
public DBAdapter(Context ctx)
{
     this.context = ctx;
     DBHelper = new DatabaseHelper(context);
}
private static class DatabaseHelper extends SQLiteOpenHelper
{
     DatabaseHelper(Context context)
     {
       super(context,DATABASE_NAME,null,DATABASE_VERSION);
     }
     //@Override
     public void onCreate(SQLiteDatabase db)
     {
        db.execSQL(DATABASE_CREATE);
     }
     //@Override
     public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion)
     {
       Log.w(TAG,"Upgrading database from version "+oldVersion+" to "
              +newVersion+", which will destroy all old data");
       db.execSQL("DROP TABLE IF EXISTS titles");
       onCreate(db);
     }
}

阅读(4530) | 评论(0) | 转发(0) |
0

上一篇:素材

下一篇:DBAdapter 2

给主人留下些什么吧!~~