Hi everybody!
Can someone help me to see more clearly when I click on the Login button, the android studio emulator shows me this: App has stopped, open again,
here are my codes:
Databasehelper:
- public class DatabaseHelper extends SQLiteOpenHelper {
-
- private static final int DATABASE_VERSION=1;
- private static final String DATABASE_NAME="Donsang.db";
- private static final String TABLE_NAME="Inscription";
- private static final String COLUMN_ID="id";
- private static final String COLUMN_PSEUDO="pseudo";
- private static final String COLUMN_NAME="nom";
- private static final String COLUMN_PHONE="phone";
- private static final String COLUMN_NAISSANCE="naissance";
-
- private static final String COLUMN_DATEDON="datedon";
-
- private static final String COLUMN_IMAGE="image";
-
- SQLiteDatabase db;
-
- private static final String TABLE_CREATE="create table Inscription (id integer primary key not null auto_increment,"+
- "pseudo text not null,nom text not null,phone text not null,naissance text not null" +
- "datedon text not null,image Blob";
-
-
- public DatabaseHelper(Context context)
- {
- super(context,DATABASE_NAME,null,DATABASE_VERSION);
-
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
-
-
- db.execSQL(TABLE_CREATE);
- this.db=db;
-
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int i, int i1) {
- String query="DROP TABLE IF EXISTS " + TABLE_NAME;
- db.execSQL(query);
- this.onCreate(db);
-
- }
-
- public boolean insertData(String pseudo,String nom,String phone,String naissance,String datedon,
- String image)
- {
-
- SQLiteDatabase db=this.getWritableDatabase();
- ContentValues contentValues=new ContentValues();
- contentValues.put(COLUMN_PSEUDO,pseudo);
- contentValues.put(COLUMN_NAME,nom);
- contentValues.put(COLUMN_PHONE,phone);
- contentValues.put(COLUMN_NAISSANCE,naissance);
-
- contentValues.put(COLUMN_DATEDON,datedon);
-
- contentValues.put(COLUMN_IMAGE,image);
-
- long result= db.insert(TABLE_NAME,null,contentValues);
- if(result==-1)
- return false;
- else
- return true;
- }
-
-
- public List<Inscription> getAll()
- {
- String[] columns = {
- COLUMN_PSEUDO,
- COLUMN_NAME,
- COLUMN_PHONE,
- COLUMN_NAISSANCE,
- COLUMN_DATEDON,
- COLUMN_IMAGE
- };
-
- String sortOrder =
- COLUMN_PSEUDO + " ASC";
- List<Inscription> inscritList = new ArrayList<Inscription>();
-
- SQLiteDatabase db = this.getReadableDatabase();
-
- Cursor cursor = db.query(TABLE_NAME,
- columns,
- null,
- null,
- null,
- null,
- sortOrder);
-
- if (cursor.moveToFirst()) {
- do {
- Inscription user = new Inscription();
- user.setId(Integer.parseInt(cursor.getString(cursor.getColumnIndex(COLUMN_ID))));
- user.setPseudo(cursor.getString(cursor.getColumnIndex(COLUMN_PSEUDO)));
- user.setNom(cursor.getString(cursor.getColumnIndex(COLUMN_NAME)));
- user.setPhone(cursor.getInt(cursor.getColumnIndex(COLUMN_PHONE)));
- user.setNaissance(cursor.getString(cursor.getColumnIndex(COLUMN_NAISSANCE)));
- user.setDate(cursor.getString(cursor.getColumnIndex(COLUMN_DATEDON)));
- user.setImage(cursor.getBlob(cursor.getColumnIndex(COLUMN_IMAGE)));
-
- inscritList.add(user);
- } while (cursor.moveToNext());
- }
- cursor.close();
- db.close();
-
-
- return inscritList;
- }
-
- public void updateInscription(Inscription inscris) {
- SQLiteDatabase db = this.getWritableDatabase();
-
- ContentValues values = new ContentValues();
- values.put(COLUMN_PSEUDO, inscris.getPseudo());
- values.put(COLUMN_NAME, inscris.getNom());
- values.put(COLUMN_PHONE, inscris.getPhone());
- values.put(COLUMN_NAISSANCE, inscris.getNaissance());
- values.put(COLUMN_DATEDON, inscris.getDate());
- values.put(COLUMN_IMAGE, inscris.getImage());
-
-
-
- db.update(TABLE_NAME, values, COLUMN_ID + " = ?",
- new String[]{String.valueOf(inscris.getId())});
- db.close();
- }
-
- public void deleteUser(Inscription user) {
- SQLiteDatabase db = this.getWritableDatabase();
-
- db.delete(TABLE_NAME, COLUMN_ID + " = ?",
- new String[]{String.valueOf(user.getId())});
- db.close();
- }
-
- public boolean checkInscris(String phone) {
-
-
- String[] columns = {
- COLUMN_ID
- };
- SQLiteDatabase db = this.getReadableDatabase();
-
-
- String selection = COLUMN_PHONE + " = ?";
-
-
- String[] selectionArgs = {phone};
-
-
-
-
-
-
-
- Cursor cursor = db.query(TABLE_NAME,
- columns,
- selection,
- selectionArgs,
- null,
- null,
- null);
- int cursorCount = cursor.getCount();
- cursor.close();
- db.close();
-
- if (cursorCount > 0) {
- return true;
- }
-
- return false;
- }
-
- public boolean checkInscris(String pseudo, String phone) {
-
-
- String[] columns = {
- COLUMN_ID
- };
- SQLiteDatabase db = this.getReadableDatabase();
-
- String selection = COLUMN_PSEUDO + " = ?" + " AND " + COLUMN_PHONE + " = ?";
-
-
- String[] selectionArgs = {pseudo, phone};
-
-
-
-
-
-
-
- Cursor cursor = db.query(TABLE_NAME,
- columns,
- selection,
- selectionArgs,
- null,
- null,
- null);
-
- int cursorCount = cursor.getCount();
- cursor.close();
-
- if (cursorCount > 0) {
- return true;
- }
-
- db.close();
- return false;
-
-
-
- }