Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Android Room: I'm having an issue with Android Room not passing an update to the database

 
Ranch Hand
Posts: 66
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

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.

My Problem:
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.

StackOverflow: https://stackoverflow.com/questions/61209892/why-isnt-my-android-room-dao-not-updating-my-entity-i-e-table

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.

Notes table: Contains a Primary Key for each note corresponding to primary keys of 7 associated note related data.
Questions table: 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:

 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic