Exception when searching in Sqlite bank

Asked

Viewed 254 times

1

12-10 09:25:36.029: D/dalvikvm(21543): VFY: replacing opcode 0x6e at 0x0002
12-10 09:25:36.279: I/Adreno-EGL(21543): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
12-10 09:25:36.279: I/Adreno-EGL(21543): OpenGL ES Shader Compiler Version: E031.24.00.08
12-10 09:25:36.279: I/Adreno-EGL(21543): Build Date: 03/21/14 Fri
12-10 09:25:36.279: I/Adreno-EGL(21543): Local Branch: AU200+patches_03212014
12-10 09:25:36.279: I/Adreno-EGL(21543): Remote Branch: 
12-10 09:25:36.279: I/Adreno-EGL(21543): Local Patches: 
12-10 09:25:36.279: I/Adreno-EGL(21543): Reconstruct Branch: 
12-10 09:25:36.319: D/OpenGLRenderer(21543): Enabling debug mode 0
12-10 09:25:36.389: D/OpenGLRenderer(21543): GL error from OpenGLRenderer: 0x502
12-10 09:25:36.389: E/OpenGLRenderer(21543):   GL_INVALID_OPERATION
12-10 09:30:52.759: D/OpenGLRenderer(21543): GL error from OpenGLRenderer: 0x502
12-10 09:30:52.769: E/OpenGLRenderer(21543):   GL_INVALID_OPERATION

Follow my source

public Cursor LoginExisteBanco(Context context, DB_Helper objDBHelper, CL_Login objLogin){
    try{
        SQLiteDatabase db;
        db = objDBHelper.getWritableDatabase();
        Cursor c = db.rawQuery("SELECT email,senha FROM usuario", null);
        return c;
    }
    catch(SQLException erro)
    {
        return null;
    }
}

he doesn’t even catch for this reason I can’t see what error is happening. It goes straight to return null.

  • Using an AVD? See if Acceleration hardware is set.

  • Add: erro.printStackTrace(); within your catch, before the return null;. Then share with us the details of the exception.

  • 1

    Log.e("erro", erro.printStackTrace().toString();) @Math is Android.

  • @Jorgeb. ops! thanks

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

1 answer

3

First, if you’re running the return null; then it’s falling into the catch.

You cannot see the error because you are hiding it. The solution to this is simple, stop hiding it. Remove the try-catch and let the application break. It will show the error to you.

Knowing which error is easier to resolve what is causing it.

Programmers need to learn not to use things automatically. You need to understand why to put or take something out in the code without following ready-made formulas.

I I talk a lot about exceptions and how there is abuse of them. I am not saying that this is a case of abuse in normal use, but to find the problem she is disturbing.

Follow the links for a response I posted and subsequent ones to better understand the use of exception. This is a complex resource that is often misused bringing unnecessary inconvenience.

Yeah, I know, it didn’t solve your real problem, but this will help you in all your work more than this solution. In the current form of your question no one can solve the problem, not even you. I did not answer this by waiting for this answer to be accepted, just to add important information.

In this specific case you can use the solution posted in the comments and just print the stack trace before the execution ends. This will not always be the best thing to do.

  • There are certain cases where Try catch is required otherwise it won’t even compile @bigown.

  • @Jorgeb. Why?

  • 1

    Java for Android. @bigown

  • @Paulohdsousa answered the question.

  • Did you misrepresent Java altogether? I thought it was just API differences. Is this case required? Is there any place that says this?

  • Eclipse when you play says you won’t compile because you might make a mistake. @bigown

  • 1

    That is, Eclise made any method like checked Exception on its own? I have seen examples using these methods without the try-catch. So it looks like it’s an IDE problem more disrupting than helping.

  • @bigown there are even a few try-catch required, such as for reading files. In this case specific is not required. And no problem with the IDE.

  • @Jorgeb. and is mandatory even without the use of throws? That’s my question. If Android Java misrepresented this.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.