Skip to content

Commit a991cb9

Browse files
authored
Create MyDatabaseHelper
1 parent 90ec143 commit a991cb9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

MyDatabaseHelper

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.example.contextprovider;
2+
3+
import android.content.Context;
4+
import android.database.sqlite.SQLiteDatabase;
5+
import android.database.sqlite.SQLiteOpenHelper;
6+
import android.widget.Toast;
7+
8+
public class MyDatabaseHelper extends SQLiteOpenHelper {
9+
public static final String CREATE_CONTENT = "create table content ("
10+
+ "id integer primary key autoincrement, "
11+
+ "number String, "
12+
+ "name text)";
13+
private Context mContext;
14+
public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
15+
super(context, name, factory, version);
16+
mContext = context;
17+
}
18+
@Override
19+
public void onCreate(SQLiteDatabase db) {
20+
db.execSQL(CREATE_CONTENT);
21+
Toast.makeText(mContext, "Create succeeded",
22+
Toast.LENGTH_SHORT).show();
23+
}
24+
@Override
25+
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
26+
}
27+
}

0 commit comments

Comments
 (0)