1.今日收获内容
第一二阶段基本完成今天写了浏览
package com.example.myapplication2; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.widget.TextView; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; public class liulan extends AppCompatActivity { private DatabaseHelper dbHelper; String str=""; String name2=""; protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chakan); Bundle bundle = getIntent().getExtras(); name2= bundle.getString("name"); final TextView tv=(TextView)findViewById(R.id.kk); dbHelper=new DatabaseHelper(this,"TTList3.db",null,3); SQLiteDatabase db=dbHelper.getWritableDatabase(); Cursor cursor = db.query("TTList3", null, "姓名=?", new String[]{name2}, null, null, null);//读取数据库所有信息 // Cursor cursor=db.query("tt",null,"专业=?",new String[]{"软件工程"}, //null,null,null);//读取数据库里面专业是软件工程的所有信息 if(cursor.moveToFirst()){ do{ String name=cursor.getString(cursor.getColumnIndex("姓名")); String tt=cursor.getString(cursor.getColumnIndex("体温")); String time=cursor.getString(cursor.getColumnIndex("日期时间")); String location=cursor.getString(cursor.getColumnIndex("所在地")); String zhuangkuang=cursor.getString(cursor.getColumnIndex("状况")); str+="姓名:"+name+" 体温:"+tt+" 日期:"+time+" 所在地:"+location+" "+" 状况:"+zhuangkuang+" ";//将数据库信息存到str中并换行 }while (cursor.moveToNext()); } cursor.close(); tv.setText(str);//打印信息 } }
2.遇到的问题
浏览直接显示了,不太好看
3.明天目标
把定位说一下