• 2021/02/9


    进行数据的查找

    package com.example.bookkeeping;
    
    import android.content.Intent;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.util.Log;
    import android.widget.Button;
    import android.widget.TextView;
    
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;
    
    public class chazhao2 extends AppCompatActivity {
        private MyDatabaseHelper dbHelper;
        String str="";
    
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_chaozhao2);
    
            Bundle bundle = getIntent().getExtras();
           String name= bundle.getString("name");
    
            Log.d("chazhao2","name"+name);
            final TextView tv=(TextView)findViewById(R.id.mm);
            dbHelper=new MyDatabaseHelper(this,"zhangben.db",null,4);
            SQLiteDatabase db=dbHelper.getWritableDatabase();
             Cursor cursor=db.query("zhangben",null,"时间=?",new String[]{name},
            null,null,null);//读取数据库里面专业是软件工程的所有信息
            if(cursor.moveToFirst()){
                do{
                    String ye=cursor.getString(cursor.getColumnIndex("盈亏"));
                    String why=cursor.getString(cursor.getColumnIndex("原因"));
                    String money=cursor.getString(cursor.getColumnIndex("金额"));
                    String time=cursor.getString(cursor.getColumnIndex("时间"));
                    Log.d("chazhao2","盈亏为:"+ye);
                    Log.d("chazhao2","原因为:"+why);
                    Log.d("chazhao2","金额为:"+money);
                    Log.d("chazhao2","时间为:"+time);
                    str+=ye+"   "+ "    "+why+"     金额:"+money+""+time+"
    ";//将数据库信息存到str中并换行
                }while (cursor.moveToNext());
            }
            cursor.close();
            tv.setText(str);//打印信息
        }
    }
  • 相关阅读:
    给X轴添加滚动条,放大X轴Y轴
    win7下发布网站
    asp.net播放声音
    用Flash方式动态生成图表
    debian programming guid
    php 自动跳转的3种方法
    用expect实现su c功能,身份切换
    11 Top Opensource Resources for Cloud Computing
    转:Linux系统下Shell命令行快捷键实用技巧
    sed 替换
  • 原文地址:https://www.cnblogs.com/qiangini/p/14905038.html
Copyright © 2020-2023  润新知