community I am new in the development on android and I am working on a creation that creates a bd, it turns out that the methods to create and add data work for me but when I run the application I try the method to get the data of the bd closes me the application, I do not know what this is, I have tried a thousand ways and different Internet codes but the application is closed just when I run the sintaxix that returns a cursor, please if someone could help me with this'public class EntryHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME="compliantBD";
public EntryHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL("create table if not exists " + classEnty.Entry.TABLE_NAME
+ " ("
+ classEnty.Entry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT , "
+ classEnty.Entry.NAME + " TEXT NOT NULL, "
+ classEnty.Entry.DIA + " INT NOT NULL"
+ classEnty.Entry.MES + " INT NOT NULL"
+ classEnty.Entry.ANO + " INT "
+ " ) ");
//insert into table
//Create("1","gera","5645454");
}
catch (SQLiteException e){
//arreglar exeption
System.out.print("error en la bd");
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public void Create(String NAME,Integer DIA,Integer Mes,Integer ANO){
SQLiteDatabase db=this.getWritableDatabase();
try{
if (db != null) {
ContentValues contentValues = new ContentValues();
contentValues.put("NAME", NAME);
contentValues.put("DIA", DIA);
contentValues.put("MES", Mes);
contentValues.put("ANO", ANO);
db.insert(classEnty.Entry.TABLE_NAME, null, contentValues);
}
db.close();
}catch (SQLiteException e){
System.out.print("error bd");
}
}
public ArrayList getLIst(){
ArrayList<Item> list=new ArrayList<Item>();
SQLiteDatabase db=this.getWritableDatabase();
if(db!=null){
String[] valores_recuperar = {classEnty.Entry._ID, classEnty.Entry.NAME,classEnty.Entry.DIA,classEnty.Entry.MES,classEnty.Entry.ANO};
System.out.print("error bd");
// aqui es donde me cierra la appcuando la ejecuto con el movil
Cursor cursor=db.query(classEnty.Entry.TABLE_NAME,valores_recuperar,null,null,null,null,null,null);
//Cursor cursor=db.rawQuery("select * from "+ classEnty.Entry.TABLE_NAME,null) ;
/ * if (cursor.moveToFirst ()) {
while (cursor.moveToNext()){
Item item=new Item(cursor.getString(0),cursor.getString(1),cursor.getInt(2),cursor.getInt(3),cursor.getInt(4));
list.add(item);
}
}
*/
}
else {
}
db.close();
return list; }
public ArrayList recuperarCONTACTOS() {
SQLiteDatabase db = getReadableDatabase();
ArrayList<Item> list=new ArrayList<Item>();
String[] valores_recuperar = {classEnty.Entry._ID, classEnty.Entry.NAME,classEnty.Entry.DIA,classEnty.Entry.MES,classEnty.Entry.ANO};
Cursor c = db.query(classEnty.Entry.TABLE_NAME, valores_recuperar,
null, null, null, null, null, null);
/* c.moveToFirst();
do {
Contactos contactos = new Contactos(c.getInt(0), c.getString(1),
c.getInt(2), c.getString(3));
lista_contactos.add(contactos);
} while (c.moveToNext());
db.close();
c.close();*/
return list;
}
'