-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28db88d
commit 728541d
Showing
7 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/example/taskmanager/Database/RoomDB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.taskmanager.Database; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.room.Database; | ||
import androidx.room.Room; | ||
import androidx.room.RoomDatabase; | ||
|
||
import com.example.taskmanager.Utility.TaskModel; | ||
|
||
@Database(entities = {TaskModel.class}, version = 1) | ||
public abstract class RoomDB extends RoomDatabase { | ||
private static volatile RoomDB INSTANCE; | ||
public abstract TaskDAO taskDAO (); | ||
|
||
public static RoomDB getInstance(Context context){ | ||
if (INSTANCE == null){ | ||
synchronized (RoomDB.class) { | ||
if (INSTANCE == null){ | ||
INSTANCE = Room.databaseBuilder(context.getApplicationContext(), RoomDB.class, "TASK_DB").build(); | ||
} | ||
} | ||
} | ||
return INSTANCE; | ||
} | ||
|
||
public void insertTask(TaskModel task){ | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/example/taskmanager/Database/TaskDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.example.taskmanager.Database; | ||
|
||
import androidx.room.Dao; | ||
import androidx.room.Delete; | ||
import androidx.room.Insert; | ||
import androidx.room.Query; | ||
import androidx.room.Update; | ||
|
||
import com.example.taskmanager.Utility.TaskModel; | ||
|
||
import java.util.List; | ||
|
||
@Dao | ||
public interface TaskDAO { | ||
@Insert | ||
void insertTask(TaskModel task); | ||
|
||
@Delete | ||
void deleteTask(TaskModel task); | ||
|
||
@Update | ||
void updateTask(TaskModel task); | ||
|
||
@Query("SELECT * FROM task_table") | ||
List<TaskModel> getAllTasks(); | ||
|
||
@Query("SELECT * FROM task_table WHERE id LIKE :taskId") | ||
TaskModel findTaskById(int taskId); | ||
|
||
@Query("SELECT * FROM task_table WHERE status LIKE 0") | ||
List<TaskModel> getAllOngoingTasks(); | ||
|
||
@Query("SELECT * FROM task_table WHERE status LIKE 1") | ||
List<TaskModel> getAllCompletedTasks(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters