デバッグなう
This commit is contained in:
parent
b29545dc0d
commit
0c569b0a57
|
@ -3,7 +3,7 @@ package com.example.oplogy;
|
||||||
import androidx.room.Database;
|
import androidx.room.Database;
|
||||||
import androidx.room.RoomDatabase;
|
import androidx.room.RoomDatabase;
|
||||||
|
|
||||||
@Database(entities = {SetUpTable.class}, version = 2, exportSchema = false)
|
@Database(entities = {SetUpTable.class}, version = 3, exportSchema = false)
|
||||||
public abstract class AppDatabase extends RoomDatabase {
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
// データベースにアクセスするためのメソッドを提供する
|
// データベースにアクセスするためのメソッドを提供する
|
||||||
public abstract SetUpTableDao setUpTableDao();
|
public abstract SetUpTableDao setUpTableDao();
|
||||||
|
|
|
@ -176,7 +176,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
// タスク1: ローカルDBから生徒数を取得してtotalStudentと比較
|
// タスク1: ローカルDBから生徒数を取得してtotalStudentと比較
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
||||||
|
.fallbackToDestructiveMigration()
|
||||||
|
.build();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
|
|
||||||
Log.d("MainActivity", "db" + setUpTableDao.getAll());
|
Log.d("MainActivity", "db" + setUpTableDao.getAll());
|
||||||
|
@ -341,7 +343,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
//roomからclassIdを取得
|
//roomからclassIdを取得
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
||||||
|
.fallbackToDestructiveMigration()
|
||||||
|
.build();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
classId = setUpTableDao.getClassId();
|
classId = setUpTableDao.getClassId();
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,11 +127,8 @@ public class SetUpActivity extends FragmentActivity
|
||||||
|
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
//roomのインスタンスを作成
|
//roomのインスタンスを作成
|
||||||
AppDatabase db = Room.databaseBuilder(
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
||||||
getApplicationContext(),
|
.fallbackToDestructiveMigration()
|
||||||
AppDatabase.class,
|
|
||||||
"SetUpTable"
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
// Roomの操作を行う
|
// Roomの操作を行う
|
||||||
|
|
Loading…
Reference in New Issue
Block a user