简单的Android Sqlite 使用

作者:青岛澄润国际贸易有限公司 来源:www.usabcc.com 发布时间:2017-09-11 13:57:56
简单的Android Sqlite 使用

简单的Android Sqlite 使用:

package com.pdsu.db_test; import java.sql.Date; import android.app.Activity; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SQLiteDatabase db = openOrCreateDatabase(test.db, MODE_PRIVATE, null); // db.execSQL(CREATE TABLE IF NOT EXISTS person (number INT(11),name // VARCHAR(255),birthday DATE);); db.execSQL(insert into person (number,name,birthday) values(12,zhangqing,?50803);); Cursor cursor = db.query(person, null, null, null, null, null, null); cursor.moveToFirst(); while (cursor.moveToNext()) { int number = cursor.getInt(0); String name = cursor.getString(1); String date = cursor.getString(2); Toast.makeText(this, number + >> + name + >> + date, 0).show(); } Toast.makeText(this, cursor.toString(), Toast.LENGTH_SHORT).show(); } }

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:黄冈SEO http://huanggang.4567w.com

  • 上一篇:代码中的$form各表示什么,该如何解决
  • 下一篇:最后一页
  •