*
My problem
Recently, I ran some of my Java code [Open Helper] through android studio , and it gave the following error : I have an login page with android (java code) and just my problem when time that must be password just string put , will be true. but if was put numerical password , will not true . code SqlOpenHelper
package com.example.root.sql2;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.Nullable;
public class db extends SQLiteOpenHelper {
public db(Context context) {
super(context, "login.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE USER(ID INTEGER PRIMARY KEY AUTOINCREMENT ,NAME TEXT, PASSWORD TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS USER");
onCreate(sqLiteDatabase);
}
public boolean insert (String name , String password){
SQLiteDatabase db = getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("NAME", name);
contentValues.put("PASSWORD", password);
long ins = db.insert("USER","",contentValues);
if (ins == -1) return false;
else return true;
}
public boolean login(String name , String password){
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM USER WHERE NAME=? AND PASSWORD=?", new String[] {name , password});
cursor.moveToFirst();
if (cursor.getCount()>0) return false;
else return true;
}
}
"password" if was string ,password then is true but "password" if was string ,password(numerical) then will not true ... *