데이터베이스 동시 접근 – Sqlite
SQLiteOpenHelper 구현이 되어있다고 다음과 같이 가정해보자. public class DatabaseHelper extends SQLiteOpenHelper {... } 자 그럼 여기서 서로 다른 쓰레드에서 다음과 같이 데이터베이스 데이터를 접근하는 코드를 만들어 본다. // 쓰레드 1 Context context =getApplicationContext(); DatabaseHelperhelper = new DatabaseHelper(context); SQLiteDatabasedatabase = helper.getWritableDatabase(); database.insert(…); database.close(); // 쓰레드 2 Context context =getApplicationCont..
2023.01.13