Android 数据存储
2010-04-10 04:46:00 来源:WEB开发网66. Log.i("haiyang:createDB=", sql);
67. db.execSQL(sql);
68. }
69.
70. @Override
71. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
72. }
73. }
74.
75. @Override
76. public void onCreate(Bundle savedInstanceState) {
77. super.onCreate(savedInstanceState);
78. setContentView(R.layout.main);
79. prepareListener();
80. initLayout();
81. mOpenHelper = new DatabaseHelper(this);
82.
83. }
84.
85. private void initLayout() {
86. button1 = (Button) findViewById(R.id.button1);
87. button1.setOnClickListener(listener1);
88.
89. button2 = (Button) findViewById(R.id.button2);
90. button2.setOnClickListener(listener2);
91.
92. button3 = (Button) findViewById(R.id.button3);
93. button3.setOnClickListener(listener3);
94.
95. button4 = (Button) findViewById(R.id.button4);
96. button4.setOnClickListener(listener4);
97.
98. button5 = (Button) findViewById(R.id.button5);
99. button5.setOnClickListener(listener5);
100.
101. }
102.
103. private void prepareListener() {
104. listener1 = new OnClickListener() {
105. public void onClick(View v) {
106. CreateTable();
107. }
108. };
109. listener2 = new OnClickListener() {
110. public void onClick(View v) {
111. dropTable();
112. }
113. };
114. listener3 = new OnClickListener() {
115. public void onClick(View v) {
116. insertItem();
117. }
118. };
119. listener4 = new OnClickListener() {
更多精彩
赞助商链接