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(); 注释掉就可以 

你可能感兴趣的:(android java.lang.IllegalStateException: database not open 错误)