Exception when searching the SQLite database

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;
    }
}

It does not even catch catch so I can not see which error is happening. Goes straight to return null .

    
asked by anonymous 10.12.2014 / 18:32

1 answer

3

First, if you are running return null; then you are falling in catch .

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

Knowing the error makes it easier to resolve what is causing it.

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

I I talk a lot about exceptions and how they abuse them. I'm not saying that this is a case of abuse in normal use, but to find the problem it's messing up.

Follow the links for my post and subsequent answers to better understand your use of exception. This is a complex feature that is often misused by bringing unnecessary inconvenience.

Yes, I know, it did not 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 hoping this answer would be accepted, just to add some important information.

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

    
10.12.2014 / 18:48