This issue seems kind of basic, and I have performed it successfully in the past. I'm not sure why it isn't working here in a different app. I hope someone may observe something I'm not seeing.
I cannot get Android Room to updated my app database. I am new to Android, but not Java, and I'm having trouble with Android Room not updating my application database. I'm not totally unfamiliar with Android Room, I performed a couple tutorials and I created a Note taking app using Android Room which adds, updates and deletes entries and it works - and I actually use it. I've in essence duplicated this method of updating in my app but I am not having any success.
What I have done:
I have stepped through the code step-by-step, and I can see the old and new data for updating. I also see it passed through Android Room code. The first thing I did was compare my coding to the Note app tutorial I created and in concept, my code appears correctly implemented. I've tried researching similar issues on the Internet but most of the time they are tutorials on how to implements updates using Android Room - not an issue related post. I did resort to posting to StackOverflow two weeks ago but have not received any suggestions, and probably because like me, everything looks good I posted. I decided I would try posting here since I learned lot about Java here and everyone has always been very knowledgeable and supportive.
A little background, the code and how it is intended to work:
The database is an ASSET and it is copied to an internal location under the app folder location (e.g. data/data/[com.app]/databases/myDatabase.db).Below is the code. This issue involves two tables, a Notes table and Questions table.
Contains a Primary Key for each note corresponding to primary keys of 7 associated note related data.
Contains a specific question that may be specific to one or multiple notes.
Initialization of the Notes data:
Pulling the Notes data associated to the current view. vNoteID is the note ID passed by an Intent
In this scenario, if the question data is different (which it is), update the current question:
Here the Questions Entity table is initialized and the current Questions object is pulled from the Questions table from the QuestionID in the Notes object above. The change is passed to the Questions Entity setQuestion method. The Questions object is then passed through the annotated @Update method in the related QuestionsDao.
The Questions Entity and Dao involved: