forked from sambitmanna/Sambit-Manna
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistory.java
More file actions
51 lines (37 loc) · 1.65 KB
/
History.java
File metadata and controls
51 lines (37 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.example.finaleapp;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class History extends AppCompatActivity {
HealthDatabaseHelper dbHelper;
TextView textViewData; // Or use RecyclerView for a better UI
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
textViewData = findViewById(R.id.tv_data); // Make sure this TextView exists in layout
dbHelper = new HealthDatabaseHelper(this);
Cursor cursor = dbHelper.getAllData();
StringBuilder data = new StringBuilder();
if (cursor.getCount() == 0) {
data.append("No data found");
} else {
while (cursor.moveToNext()) {
data.append("Time: ").append(cursor.getString(6)).append("\n")
.append("BPM: ").append(cursor.getInt(1)).append("\n")
.append("Temp: ").append(cursor.getFloat(2)).append("°F\n")
.append("SpO2: ").append(cursor.getInt(3)).append("%\n")
.append("RR: ").append(cursor.getInt(4)).append(" bpm\n")
.append("HRV: ").append(cursor.getInt(5)).append(" ms\n\n");
}
}
textViewData.setText(data.toString());
}
}