代码是这样:
import SQLiteOpenHelper from 'android.database.sqlite.SQLiteOpenHelper';
import SQLiteDatabase from 'android.database.sqlite.SQLiteDatabase';
import Context from 'android.content.Context';
export class XyDBHelper extends SQLiteOpenHelper {
private static TABLE_NAME : String = "xy_search_list"
private static TABLE_VERSION : Number = 1
private static COLUMN_ID = 'id'
private static COLUMN_DESC = 'desc'
private static COLUMN_URL = 'url'
private static COLUMN_CREATE_TIME = 'create_time'
constructor(context : Context) {
super(context, XyDBHelper.TABLE_NAME, null, XyDBHelper.TABLE_VERSION)
}
override onCreate(db : SQLiteDatabase) {
}
public override onUpgrade(param0 : SQLiteDatabase, param1 : number, param2 : number) {
// console.log('onUpgrade',param1,param2)
// param0.execSQL("DROP TABLE IF EXISTS "+XyDBHelper.TABLE_NAME)
// this.onCreate(param0)
}
}
但是编译出错,我在java是可以用的
'XyDBHelper' is not abstract and does not implement abstract base class member public abstract fun onUpgrade(p0: SQLiteDatabase!, p1: Int, p2: Int): Unit defined in android.database.sqlite.SQLiteOpenHelper
rror: None of the following functions can be called with the arguments supplied:
17:14:13.098 public constructor SQLiteOpenHelper(p0: Context?, p1: String?, p2: SQLiteDatabase.CursorFactory?, p3: Int) defined in android.database.sqlite.SQLiteOpenHelper
17:14:13.110 public constructor SQLiteOpenHelper(p0: Context?, p1: String?, p2: Int, p3: SQLiteDatabase.OpenParams) defined in android.database.sqlite.SQLiteOpenHelper
error: 'onUpgrade' overrides nothing
真是炸裂
1 个回复
tangyx (作者)
补充一下,export class XyDBHelper extends SQLiteOpenHelper