标签:lis ase ring div value pre 语句 轻量级 sql语句
@OnClick({R.id.click1, R.id.click2, R.id.click3, R.id.click4}) public void onViewClicked(View view) { mDb = mMyOpenHelper.getWritableDatabase(); switch (view.getId()) { case R.id.click1: mDb.execSQL("insert into loginin(name,phone) values(‘a‘,‘18634757219‘)"); break; case R.id.click2: mDb.execSQL("delete from loginin where name=‘a‘"); break; case R.id.click3: mDb.execSQL("update loginin set phone = ‘18634757219‘ where name=‘a‘"); break; case R.id.click4: Cursor cursor = mDb.rawQuery("select * from loginin", null); if (cursor!=null){ while(cursor.moveToNext()){ int id = cursor.getInt(0); String name = cursor.getString(1); String phone = cursor.getString(2); Log.d(TAG, "onViewClicked: "+id+"--"+name+"--"+phone); } } break; } mDb.close(); }
@OnClick({R.id.click1, R.id.click2, R.id.click3, R.id.click4}) public void onViewClicked(View view) { mDb = mMyOpenHelper.getWritableDatabase(); switch (view.getId()) { case R.id.click1: ContentValues values = new ContentValues(); values.put("name","b"); values.put("phone","18634757219"); long loginin = mDb.insert("loginin", null, values); if (loginin==-1){ Log.d(TAG, "onViewClicked: 插入失败"); }else{ Log.d(TAG, "onViewClicked: 插入成功"); } break; case R.id.click2: int delete = mDb.delete("loginin", "name=?", new String[]{"b"}); Log.d(TAG, "onViewClicked: 删除了"+delete+"行"); break; case R.id.click3: ContentValues values1 = new ContentValues(); values1.put("phone","110"); int update = mDb.update("loginin", values1, "name=?", new String[]{"b"}); if (update==-1){ Log.d(TAG, "onViewClicked: 更新失败"); }else{ Log.d(TAG, "onViewClicked: 更新成功"); } break; case R.id.click4: Cursor cursor = mDb.query("loginin", null, null, null, null, null, null); if (cursor!=null){ while(cursor.moveToNext()){ int id = cursor.getInt(0); String name = cursor.getString(1); String phone = cursor.getString(2); Log.d(TAG, "onViewClicked: "+id+"--"+name+"--"+phone); } } break; } mDb.close(); }
标签:lis ase ring div value pre 语句 轻量级 sql语句
原文地址:https://www.cnblogs.com/nangongyibin/p/10200632.html