The moose likes Android and the fly likes Problem in my application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Problem in my application" Watch "Problem in my application" New topic
Author

Problem in my application

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I used a database "Login" in my application android. This application must work in my tablette, but when i install .apk in my tablette all the data of my data base dissapear !!!
I don't know what's the problem exactly, i need your help
here's my code for database:


and here's the activity :

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
Sorry, i put another code which i change it
the problem is when i debug or i run the application doesn't work
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
here's the logcat what's display :
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
It seems that there is only a single object in line 166 of DataBaseLoginHelper which could be null. Where in the code are you assigning it a value?
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I change the line 166 by
The interface display, but there's always an error
here's the logcat :
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
NullPointerExceptions are relatively easy to debug - they even tell you the line number on which you're trying to invoke a method on a null object reference. With that knowledge, it shouldn't be hard to figure out which object is null. You can either use a debugger, or do some logcat logging at relevant locations throughout the code.
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
When i debug, it display "source not found"
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I can not determine the error
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

If you look at the stack trace you posted, which class do you think the error comes from? What line of code?


Steve
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9


Check line 362 in your DataBaseHelper. Like Ulf mentioned one of the variables is null


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
Ok, thanks
it's work now
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
BUt , when i install .apk in my tablet doesn't work .
according to you, why it doesn't work ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
Maybe because you didn't fix the cause of the exception?
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
where exactly?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
The NullPointerException. Did what Maneesh, Steve and I said make sense to you?
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I didn't understand you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
OK. What *did* you understand? Did you notice that the error message tells you exactly in which class and in which line of code the problem occurred?
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
yes, i understand that.
But, after i change my code the application works without error
here's the new code :
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
The problem is when i install it in my tablet doesn't work
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
What does "doesn't work" mean? TellTheDetails.
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
All the data of my database is lost.
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
I think that the problem is here :
in the two method.
How can i correct it ? Do you have any idea?
thanks in advance
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

First, you shouldn't have to 'think' the problem is somewhere, you need to know where it is - by correctly logging errors and viewing those logs. Don't print stacktraces because you probably won't be able to see them. Instead, use Log.e(...) to log the results so you can view them in LogCat.

Second, you should read your logs so you can tell if there is something going wrong that isn't crashing the application, but still logs as an error. There will be one (and I bet it is either an IO error preventing you from writing the file or a SQL error because the table you are trying to read doesn't exist).

Finally, you copy and pasted the code from here: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/. Did you read the comments there? There are two likely problems, both discovered on that code in 2009. One has a simple fix, and the other a not so easy fix.
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 274
Thanks for you reuest Steve.
Can you help me to define this two error ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in my application