Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read row/col from CursorWindow ? - android
    primarykey
    data
    text
    <p>this is my function to compare it....... please find the error if any.i have not logged in it</p> <pre><code>public void onClick(View v) { // TODO Auto-generated method stub String unname=username1.getText().toString(); String storedPassword1=db.getdata(unname); db.open(); try { if(password.equals(storedPassword1)) { Intent it=new Intent("com.Butterfly.bmw.ADMINLIST"); startActivity(it); } else { Toast.makeText(Database.this, "User Name or Password does not match", Toast.LENGTH_LONG).show(); System.out.println("errorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"); } db.close(); } catch (Exception e) { Toast.makeText(Database.this, "does not enter in try block", Toast.LENGTH_LONG).show(); } } }); </code></pre> <p>this is my db class please find the error from this.i have not login in this</p> <pre><code>import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class EditDatabase { public static final String KEY_USERNAME="username"; public static final String KEY_ROLE="role"; public static final String KEY_PASSWORD="password"; private static final String TAG="DbaAdapter"; private static final String DATABASE_NAME="mydatabase"; private static final String DATABASE_TABLE="login"; private static final int DATABASE_VERSION=1; private static final String DATABASE_CREATE="create table "+DATABASE_TABLE+"("+KEY_USERNAME+" text primary key ,"+KEY_PASSWORD+" text not null,"+KEY_ROLE+" text not null)"; private final Context context; private static DatabaseHelper DBhelper; private static SQLiteDatabase db; public EditDatabase(Context ctx){ this.context=ctx; DBhelper=new DatabaseHelper(context); } private static class DatabaseHelper extends SQLiteOpenHelper{ DatabaseHelper(Context context){ super(context,DATABASE_NAME,null,DATABASE_VERSION); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL("DROP TABLE IF EXISTS contacts"); onCreate(db); } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL(DATABASE_CREATE); } } public EditDatabase open() throws SQLException{ // TODO Auto-generated method stub db=DBhelper.getWritableDatabase(); return this; } public long insertDetails(String uname, String pass, String string) { // TODO Auto-generated method stub ContentValues initialValues = new ContentValues(); initialValues.put(KEY_USERNAME, uname); initialValues.put(KEY_PASSWORD, pass); initialValues.put(KEY_ROLE, "admin"); return db.insert(DATABASE_TABLE, null, initialValues); } public void close() { // TODO Auto-generated method stub DBhelper.close(); } public String getdata(String unname) { // TODO Auto-generated method stub Cursor cursor = db.rawQuery("SELECT * FROM login WHERE KEY_USERNAME=?", new String [] { unname.toString() }); if(cursor.getCount()&lt;1) // UserName Not Exist { cursor.close(); return "NOT EXIST"; } cursor.moveToFirst(); String password= cursor.getString(cursor.getColumnIndex("KEY_PASSWORD")); cursor.close(); return password; } public long insertDetailsuser(String uname, String pass, String string) { // TODO Auto-generated method stub ContentValues initialValuess = new ContentValues(); initialValuess.put(KEY_USERNAME, uname); initialValuess.put(KEY_PASSWORD, pass); initialValuess.put(KEY_ROLE, "user"); return db.insert(DATABASE_TABLE, null, initialValuess); } public Cursor getAllContacts() { // TODO Auto-generated method stub return db.query(DATABASE_TABLE, new String[] {KEY_USERNAME, KEY_PASSWORD, KEY_ROLE}, null, null, null, null, null);} public boolean deleteDetails(String uname) { // TODO Auto-generated method stub //Cursor cursor=db.rawQuery("select password from login where " + KEY_USERNAME + "='" + unname + "'", null); return db.delete(DATABASE_TABLE,KEY_USERNAME + "='" + uname + "'", null)&gt;0; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload