• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

NullPointerException error

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am building an app from start I need to say I am beginner in this area . So until now my app on button click open a popup dialog where I can add names and delete them. but the problem comes when I add a new item and try to delete one, give me crash I will put link below . It gives me NullPointerException , on a null object reference. I think problem it s at databasehandler when it need to refresh data but idk for sure. Really appreciate any comment.



and here I put error


and this is database

 
Rancher
Posts: 4761
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the code and error messages here as text, not via links.
Be sure to wrap the code in code tags: Select the code and press Code button.
 
George Machis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:Please post the code and error messages here as text, not via links.
Be sure to wrap the code in code tags: Select the code and press Code button.


I have done this i don't really know who things work here i look an answer for my problem thanks.
 
Norm Radder
Rancher
Posts: 4761
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the actual content of the variable context when line 45 is executed?
Was deleteContact called from line 46 just before the NPE?  The full text of the error message should show where that method was called from.  The posted code does not show that.
 
George Machis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:What is the actual content of the variable context when line 45 is executed?
Was deleteContact called from line 46 just before the NPE?  The full text of the error message should show where that method was called from.  The posted code does not show that.


context that i put there is a private variable declared of context type. I dont reallly  fully understand who recycle view work.
Let s say it form start first time the problem was that names doesn't live update I should close my app and after name s should show me after i put this part of code

after i called saveName(v) in line 138
and after name live update was good but after when i add a new name and try to delete any of them give me a crash
It s very frustrating for me because i don t fully understand this problem and can t resolve it solo... I look for a answer from 2 days for this
Thanks
 
George Machis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:What is the actual content of the variable context when line 45 is executed?
Was deleteContact called from line 46 just before the NPE?  The full text of the error message should show where that method was called from.  The posted code does not show that.


i used debug and the null it s like you said in variable context line 45 that is null bud i don't know how to set it up good
 
Norm Radder
Rancher
Posts: 4761
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you traced back through the chain of assignments to see where the fault is?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic