`
busuanzi
  • 浏览: 144051 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

android java.lang.IllegalStateException: database not open 错误

 
阅读更多
package com.taobao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "taobao";
	private static final int DATABASE_VERSION = 1;

	DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {

//		String sql = "CREATE TABLE " + TABLE_NAME + " (" + TITLE
//				+ " text not null, " + BODY + " text not null " + ");";
		String sql="create table  brand (id text,url text,title text)";
		String sql2="create table  faver (id text,title text)";
		db.execSQL(sql);
		db.execSQL(sql2);
		//db.close();
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	}

}




出现  java.lang.IllegalStateException: database not open 错误  db.close(); 注释掉就可以 
分享到:
评论
1 楼 cl1_1_1 2012-08-04  

相关推荐

Global site tag (gtag.js) - Google Analytics