{"rsdb":{"rid":"386215","subhead":"","postdate":"0","aid":"269189","fid":"98","uid":"1","topic":"1","content":"
\n
\n
public<\/span> class<\/span> DbOpenHelper extends<\/span> SQLiteOpenHelper {\n\n    <\/span>private<\/span> static<\/span> String name = "test.db"; \/*<\/span> \u6570\u636e\u5e93<\/a>\u540d\u79f0 <\/span>*\/<\/span>\n    private<\/span> static<\/span> int<\/span> version = 1; \/*<\/span> \u6570\u636e\u5e93<\/a>\u7248\u672c\u53f7 <\/span>*\/<\/span>\n\n    public<\/span> DbOpenHelper(Context context) {\n        <\/span>super<\/span>(context, name, null<\/span>, version);\n        <\/span>\/\/<\/span> TODO Auto-generated constructor stub<\/span>\n    }\n\n    @Override\n    <\/span>public<\/span> void<\/span> onCreate(SQLiteDatabase db) {\n        <\/span>\/\/<\/span> TODO Auto-generated method stub<\/span>\n\n        String sql <\/span>= "create table person(id integer primary key autoincrement, name varchar(64))";\n        db.execSQL(sql);\n    }\n\n    @Override\n    <\/span>public<\/span> void<\/span> onUpgrade(SQLiteDatabase db, int<\/span> oldVersion, int<\/span> newVersion) {\n        <\/span>\/\/<\/span> TODO Auto-generated method stub<\/span>\n\n    }\n}<\/span><\/pre>\n <\/div>\n 
\n
private<\/span> Button button;\n\n    @Override\n    <\/span>protected<\/span> void<\/span> onCreate(Bundle savedInstanceState) {\n        <\/span>super<\/span>.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        button <\/span>= (Button) this<\/span>.findViewById(R.id.button);\n\n        button.setOnClickListener(<\/span>new<\/span> View.OnClickListener() {\n\n            @Override\n            <\/span>public<\/span> void<\/span> onClick(View v) {\n                <\/span>\/\/<\/span> TODO Auto-generated method stub<\/span>\n\n                DbOpenHelper dbOpenHelper <\/span>= new<\/span> DbOpenHelper(MainActivity.this<\/span>);\n                dbOpenHelper.getWritableDatabase();\n            }\n        });\n    }<\/span><\/pre>\n <\/div>\n 

\"image\"<\/a><\/p> \n<\/div>","orderid":"0","title":"Android \u6570\u636e\u5e93 SQLiteOpenHelper","smalltitle":"","mid":"0","fname":"Android","special_id":"0","bak_id":"0","info":"0","hits":"15","pages":"1","comments":"0","posttime":"2019-11-18 11:20:44","list":"1574047244","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Android<\/A> \u6570\u636e\u5e93<\/A> SQLiteOpenHelper<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.35","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Android \u6570\u636e\u5e93 SQLiteOpenHelper","lastview":"1576154282","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}