0

I am developing an android application using java with SQLite. The following code make the error:

String selectQuery = "SELECT * FROM User";
Cursor cursor = db.rawQuery(selectQuery, null);

I checked my program and I found that the cursor make unfortunatly error.

Please help from where is the error come??

Edited by peter_budo: Code formatting

5
Contributors
9
Replies
29
Views
4 Years
Discussion Span
Last Post by ziadkassam
0

The main idea is that if I want to insert a record to database, there isn't an error, the error is only when selecting a record or may be using the Cursor...

0

The application stopped unfortunatly.

the database helper:

public static String getSinlgeEntry(String userName){   
     String selectQuery = "SELECT * FROM lockUser";
     Cursor cursor = db.rawQuery(selectQuery, null);
      if(cursor.getCount()<1){
          cursor.close();
          return "NOT EXIST";
      }
        cursor.close();
        return "zzzzzz";


    }

the main activity:

private OnClickListener onClick=new OnClickListener() {
        public void onClick(View v) {

        String userName=edText1.getText().toString(); 
        String password=edText2.getText().toString(); 

            String storedPassword;

                storedPassword = DBAdapter.getSinlgeEntry("ziad");
                if(storedPassword=="zzzzzz"){
                    Toast.makeText(getApplicationContext(), "Welcome ziad", Toast.LENGTH_LONG).show();
                }
                else{
                    Toast.makeText(getApplicationContext(), "Something wrong ", Toast.LENGTH_LONG).show();
                }
        }
        };
0

never heard of any database engine giving as an error "the database has stopped unfortunately".
Again, list the actual error...

0

Hi!
First check the recored is present or not. Because the Toast will never allow you to print the empty result. it will making the " unfortunatly stoped " error..,

Edited by raj.mscking

0

No matter which IDE you use there is a logcat which will tell you where error exactly happen. So check it out and stop posting generic error that you see on device screen. You are wasting our time

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.