application crashes after SQL requestHow can I prevent SQL injection in PHP?How do I perform an IF…THEN in an SQL SELECT?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to concatenate text from multiple rows into a single text string in SQL server?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableHow to use java.net.URLConnection to fire and handle HTTP requestsHow do I import an SQL file using the command line in MySQL?
To "hit home" in German
Can my boyfriend, who lives in the UK and has a Polish passport, visit me in the USA?
What are the pros and cons of Einstein-Cartan Theory?
How can I run SQL Server Vulnerability Assessment from a SQL Job?
How to dismiss intrusive questions from a colleague with whom I don't work?
How do you call it when two celestial bodies come as close to each other as they will in their current orbits?
The teacher logged me in as administrator for doing a short task, is the whole system now compromised?
Why we don't have vaccination against all diseases which are caused by microbes?
How to persuade recruiters to send me the Job Description?
Is it appropriate for a prospective landlord to ask me for my credit report?
Do I have to learn /o/ or /ɔ/ separately?
Have only girls been born for a long time in this village?
Nuclear decay triggers
Ask for a paid taxi in order to arrive as early as possible for an interview within the city
Does Swashbuckler's Fancy Footwork apply if the attack was made with Booming Blade?
Can others monetize my project with GPLv3?
How can I support the recycling, but not the new production of aluminum?
Church Booleans
What professions would a medieval village with a population of 100 need?
How to think about joining a company whose business I do not understand?
!I!n!s!e!r!t! !n!b!e!t!w!e!e!n!
How to determine if an Apex class hasn't been used recently
Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")
Are there nouns that change meaning based on gender?
application crashes after SQL request
How can I prevent SQL injection in PHP?How do I perform an IF…THEN in an SQL SELECT?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to concatenate text from multiple rows into a single text string in SQL server?Inserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableHow to use java.net.URLConnection to fire and handle HTTP requestsHow do I import an SQL file using the command line in MySQL?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My application crashes when I do a SQL request.
It says that the table doesn't exist and I don't know why.
Could you help me?
Here is the logcat:
03-27 15:35:49.718 5672-5672/descartes.info.l3ag2.eyetrek E/AndroidRuntime: FATAL EXCEPTION: main
Process: descartes.info.l3ag2.eyetrek,
PID: 5672 android.database.sqlite.SQLiteException: no such table: bddchampignons (code 1):,
while compiling: SELECT * FROM bddchampignons
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at descartes.info.l3ag2.eyetrek.classes.DatabaseHandler.getAllChampignons(DatabaseHandler.java:578)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1.lambda$onCreateView$2$FragmentCirconstance1(FragmentCirconstance1.java:147)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1$$Lambda$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
this is the request I am doing :
List<Mushroom> MushroomList = new ArrayList<Mushroom>();
MushroomList = databaseHandler.getAllChampignons();
String res= "";
Log.e("List", MushroomList.toString());
for (Mushroom mushroom: MushroomList)
Log.e("NAME", mushroom.getName());
res = res + mushroom.getId() + "n";
createAlertBox("Resultats", res);
and this is a part of the code from my DataBaseHandler class where is the method getAllChampignons
:
private static final String TABLE_CHAMPIGNON = "bddchampignons";
//(my csv file is named "bddchampignons")
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
this is my DataBaseHandler classe where I created my table, but it doesn't work ..
I'm just showing you the part where it's about champignons(mushrooms)
and you can find :
- method onCreate where the table champignons is created
- method to create an Mushroom Object
- method which return a list with the elements corresponding to the SQL request
- method which return a list with all the elements of the database
- method
public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "db_eyetrek";
private static final String TABLE_CHAMPIGNON = "bddchampignons";
private static final String CHAMP_ID = "id";
private static final String CHAMP_NAME = "name";
private static final String CHAMP_DIAMETRE_MIN = "diametreMin";
private static final String CHAMP_DIAMETRE_MAX = "diametreMax";
private static final String COULEUR_CHAPEAU = "couleurChapeau";
private static final String FORME_CHAPEAU = "formeChapeau";
private static final String SURFACE_CHAPEAU = "surfaceChapeau";
private static final String TYPE_MARGE= "typeMarge";
private static final String COULEUR_MARGE = "couleurMarge";
private static final String DESSOUS_CHAPEAU = "dessousChapeau";
private static final String COULEUR_DESSOUS_CHAPEAU = "couleurDessousChapeau";
private static final String OXYDATION_CHAPEAU = "oxydationChapeau";
private static final String COULEUR_OXYDATION_CHAPEAU = "couleurOxydationChapeau";
private static final String INSERTION_DESSOUS_PIED= "insertionDessousPied";
private static final String ESPACE_LAMELLES = "espaceLamelles";
private static final String TYPE_LAMELLES = "typeLamelles";
private static final String COULEUR_PIED = "couleurPied";
private static final String PIED_CREUX_PLEIN = "piedCreuxPlein";
private static final String FORME_PIED = "formePied";
private static final String LONGEUR_PIED = "longueurPied";
private static final String SURFACE_PIED = "surfacePied";
private static final String POSITION_PIED_CHAPEAU = "positionPiedChapeau";
private static final String PRESENCE_ANNEAU = "presenceAnneau";
private static final String ORIENTATION_ANNEAU = "orientationAnneau";
private static final String MOBILITE_ANNEAU = "mobiliteAnneau";
private static final String COULEUR_ANNEAU = "couleurAnneau";
private static final String POUSSE_TOUFFE = "pousseTouffe";
private static final String COULEUR_BASE_PIED = "couleurBasePied";
private static final String COULEUR_CHAIR = "couleurChair";
private static final String OXYDATION_CHAIR = "oxydationChair";
private static final String COULEUR_OXYDATION_CHAIR = "couleurOxydationChair";
private static final String FERMETE_CHAIR = "fermeteChair";
private static final String ODEUR = "odeur";
private static final String LATEX = "latex";
private static final String COULEUR_LATEX = "couleurLatex";
private static final String MOIS_POUSSE_TOT = "moisPousseTot";
private static final String MOIS_POUSSE_TARD = "moisPousseTard";
private static final String MILIEU = "milieu";
private static final String POUSSE_BOIS = "pousseBois";
private static final String NOM_VERNACULAIRE = "nomVernaculaire";
private static final String COMESTIBILITE = "comestibilite";
private static final String COMMENTAIRES = "commentaires";
private static final String SYNONYMES = "synonymes";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
getReadableDatabase();
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase)
//Création de la table champignon
String CREATE_CHAMPIGNON_TABLE = "create table if not exists " + TABLE_CHAMPIGNON + " ("
+ CHAMP_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + CHAMP_NAME + " VARCHAR (40),"
+ CHAMP_DIAMETRE_MIN + " INTEGER (2)," + CHAMP_DIAMETRE_MAX + " VARCHAR(3) ," + COULEUR_CHAPEAU + " VARCHAR (30)," + FORME_CHAPEAU + " VARCHAR (70),"
+ SURFACE_CHAPEAU + " VARCHAR (105)," + TYPE_MARGE + " VARCHAR (101)," + COULEUR_MARGE + " VARCHAR (11)," + DESSOUS_CHAPEAU + " VARCHAR (26),"
+ COULEUR_DESSOUS_CHAPEAU + " VARCHAR (29)," + OXYDATION_CHAPEAU + " VARCHAR(20)," + COULEUR_OXYDATION_CHAPEAU + " VARCHAR(14)," + INSERTION_DESSOUS_PIED + " VARCHAR (46),"
+ ESPACE_LAMELLES + " VARCHAR (8)," + TYPE_LAMELLES + " VARCHAR (34)," + COULEUR_PIED + " VARCHAR (22)," + PIED_CREUX_PLEIN + " VARCHAR (21),"
+ FORME_PIED + " VARCHAR (165)," + LONGEUR_PIED + " VARCHAR (10)," + SURFACE_PIED + " VARCHAR (84)," + POSITION_PIED_CHAPEAU + " VARCHAR (9),"
+ PRESENCE_ANNEAU + " VARCHAR (3)," + ORIENTATION_ANNEAU + " VARCHAR (10)," + MOBILITE_ANNEAU + " VARCHAR (6)," + COULEUR_ANNEAU + " VARCHAR (43),"
+ POUSSE_TOUFFE + " VARCHAR (3),"+ COULEUR_BASE_PIED + " VARCHAR (21)," + COULEUR_CHAIR + " VARCHAR (30)," + OXYDATION_CHAIR + " VARCHAR (3),"
+ COULEUR_OXYDATION_CHAIR + " VARCHAR (21)," + FERMETE_CHAIR + " VARCHAR (16)," + ODEUR + " VARCHAR (25)," + LATEX + " VARCHAR (3)," + COULEUR_LATEX + " VARCHAR (14),"
+ MOIS_POUSSE_TOT + " VARCHAR (19)," + MOIS_POUSSE_TARD + " VARCHAR (20)," + MILIEU + " VARCHAR (49)," + POUSSE_BOIS + " VARCHAR (3)," + NOM_VERNACULAIRE + " VARCHAR (87),"
+ COMESTIBILITE + " VARCHAR (18)," + COMMENTAIRES + " VARCHAR (332)," + SYNONYMES + " VARCHAR (34) )";
sqLiteDatabase.execSQL(CREATE_CHAMPIGNON_TABLE);
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_DIDACTICIEL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_LEAFS);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_ANIMAL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_CHAMPIGNON);
onCreate(sqLiteDatabase);
public void addChampignon (Mushroom champignon)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(CHAMP_NAME, champignon.getName());
values.put(CHAMP_DIAMETRE_MIN, champignon.getDiametreMin());
values.put(CHAMP_DIAMETRE_MAX, champignon.getDiametreMax());
values.put(COULEUR_CHAPEAU, champignon.getCouleurChapeau());
values.put(FORME_CHAPEAU, champignon.getFormeChapeau());
values.put(SURFACE_CHAPEAU, champignon.getSurfaceChapeau());
values.put(TYPE_MARGE, champignon.getTypeMarge());
values.put(COULEUR_MARGE, champignon.getCouleurMarge());
values.put(DESSOUS_CHAPEAU, champignon.getDessousChapeau());
values.put(COULEUR_DESSOUS_CHAPEAU,champignon.getCouleurDessousChapeau());
values.put(OXYDATION_CHAPEAU, champignon.getOxydationChapeau());
values.put(COULEUR_OXYDATION_CHAPEAU, champignon.getCouleurOxydationChapeau());
values.put(INSERTION_DESSOUS_PIED, champignon.getInsertionDessousPied());
values.put(ESPACE_LAMELLES, champignon.getEspaceLamelles());
values.put(TYPE_LAMELLES, champignon.getTypeLamelles());
values.put(COULEUR_PIED, champignon.getCouleurPied());
values.put(PIED_CREUX_PLEIN, champignon.getPiedCreuxPlein());
values.put(FORME_PIED, champignon.getFormePied());
values.put(LONGEUR_PIED, champignon.getLongueurPied());
values.put(SURFACE_PIED, champignon.getSurfacePied());
values.put(POSITION_PIED_CHAPEAU, champignon.getPositionPiedChapeau());
values.put(PRESENCE_ANNEAU, champignon.getPresenceAnneau());
values.put(ORIENTATION_ANNEAU, champignon.getOrientationAnneau());
values.put(MOBILITE_ANNEAU, champignon.getMobiliteAnneau());
values.put(COULEUR_ANNEAU, champignon.getCouleurAnneau());
values.put(POUSSE_TOUFFE, champignon.getPousseTouffe());
values.put(COULEUR_BASE_PIED, champignon.getCouleurBasePied());
values.put(COULEUR_CHAIR, champignon.getCouleurChair());
values.put(OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(COULEUR_OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(FERMETE_CHAIR, champignon.getFermeteChair());
values.put(ODEUR, champignon.getOdeur());
values.put(LATEX, champignon.getLatex());
values.put(COULEUR_LATEX, champignon.getCouleurLatex());
values.put(MOIS_POUSSE_TOT, champignon.getMoisPousseTot());
values.put(MOIS_POUSSE_TARD, champignon.getMoisPousseTard());
values.put(MILIEU, champignon.getMilieu());
values.put(POUSSE_BOIS, champignon.getPousseBois());
values.put(NOM_VERNACULAIRE, champignon.getNomVernaculaire());
values.put(COMESTIBILITE, champignon.getComestibilite());
values.put(COMMENTAIRES, champignon.getCommentaires());
values.put(SYNONYMES, champignon.getSynonymes());
db.insert(TABLE_CHAMPIGNON, null, values);
db.close();
/**
* Retourne une liste des champignons correspondant à la requête
*
* @param query
* @return
*/
public List<Mushroom> getChampignonFromRequest(String query)
List<Mushroom> mushroomList = new ArrayList<Mushroom>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
mushroomList.add(champ);
while (cursor.moveToNext());
cursor.close();
return mushroomList;
/**
* Ajout des Champignons depuis& un CSV
*
* @param inputStream
* @param context
*/
public void addChampignonFromCsv(InputStream inputStream, Context context)
DatabaseHandler db = new DatabaseHandler(context);
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine())
String line = scanner.nextLine();
String str[] = line.split(";");
db.addChampignon(new Mushroom(Integer.parseInt(str[0]), str[1], Integer.parseInt(str[2]), Integer.parseInt(str[3]),str[4],str[5],
str[6],str[7],str[8],str[9],str[10],str[11],str[12],str[13],str[14],str[15],
str[16],str[17],str[18],str[19],str[20],str[21],str[22],str[23],str[24],str[25],
str[26],str[27],str[28],str[29],str[30],str[31],str[32],str[33],str[34],str[35],
str[36],str[37],str[38],str[39],str[40],str[41],str[42]));
scanner.close();
/**
* Retourne tous les champignons de la base de données
*
* @return
*/
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
java sql
add a comment |
My application crashes when I do a SQL request.
It says that the table doesn't exist and I don't know why.
Could you help me?
Here is the logcat:
03-27 15:35:49.718 5672-5672/descartes.info.l3ag2.eyetrek E/AndroidRuntime: FATAL EXCEPTION: main
Process: descartes.info.l3ag2.eyetrek,
PID: 5672 android.database.sqlite.SQLiteException: no such table: bddchampignons (code 1):,
while compiling: SELECT * FROM bddchampignons
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at descartes.info.l3ag2.eyetrek.classes.DatabaseHandler.getAllChampignons(DatabaseHandler.java:578)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1.lambda$onCreateView$2$FragmentCirconstance1(FragmentCirconstance1.java:147)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1$$Lambda$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
this is the request I am doing :
List<Mushroom> MushroomList = new ArrayList<Mushroom>();
MushroomList = databaseHandler.getAllChampignons();
String res= "";
Log.e("List", MushroomList.toString());
for (Mushroom mushroom: MushroomList)
Log.e("NAME", mushroom.getName());
res = res + mushroom.getId() + "n";
createAlertBox("Resultats", res);
and this is a part of the code from my DataBaseHandler class where is the method getAllChampignons
:
private static final String TABLE_CHAMPIGNON = "bddchampignons";
//(my csv file is named "bddchampignons")
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
this is my DataBaseHandler classe where I created my table, but it doesn't work ..
I'm just showing you the part where it's about champignons(mushrooms)
and you can find :
- method onCreate where the table champignons is created
- method to create an Mushroom Object
- method which return a list with the elements corresponding to the SQL request
- method which return a list with all the elements of the database
- method
public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "db_eyetrek";
private static final String TABLE_CHAMPIGNON = "bddchampignons";
private static final String CHAMP_ID = "id";
private static final String CHAMP_NAME = "name";
private static final String CHAMP_DIAMETRE_MIN = "diametreMin";
private static final String CHAMP_DIAMETRE_MAX = "diametreMax";
private static final String COULEUR_CHAPEAU = "couleurChapeau";
private static final String FORME_CHAPEAU = "formeChapeau";
private static final String SURFACE_CHAPEAU = "surfaceChapeau";
private static final String TYPE_MARGE= "typeMarge";
private static final String COULEUR_MARGE = "couleurMarge";
private static final String DESSOUS_CHAPEAU = "dessousChapeau";
private static final String COULEUR_DESSOUS_CHAPEAU = "couleurDessousChapeau";
private static final String OXYDATION_CHAPEAU = "oxydationChapeau";
private static final String COULEUR_OXYDATION_CHAPEAU = "couleurOxydationChapeau";
private static final String INSERTION_DESSOUS_PIED= "insertionDessousPied";
private static final String ESPACE_LAMELLES = "espaceLamelles";
private static final String TYPE_LAMELLES = "typeLamelles";
private static final String COULEUR_PIED = "couleurPied";
private static final String PIED_CREUX_PLEIN = "piedCreuxPlein";
private static final String FORME_PIED = "formePied";
private static final String LONGEUR_PIED = "longueurPied";
private static final String SURFACE_PIED = "surfacePied";
private static final String POSITION_PIED_CHAPEAU = "positionPiedChapeau";
private static final String PRESENCE_ANNEAU = "presenceAnneau";
private static final String ORIENTATION_ANNEAU = "orientationAnneau";
private static final String MOBILITE_ANNEAU = "mobiliteAnneau";
private static final String COULEUR_ANNEAU = "couleurAnneau";
private static final String POUSSE_TOUFFE = "pousseTouffe";
private static final String COULEUR_BASE_PIED = "couleurBasePied";
private static final String COULEUR_CHAIR = "couleurChair";
private static final String OXYDATION_CHAIR = "oxydationChair";
private static final String COULEUR_OXYDATION_CHAIR = "couleurOxydationChair";
private static final String FERMETE_CHAIR = "fermeteChair";
private static final String ODEUR = "odeur";
private static final String LATEX = "latex";
private static final String COULEUR_LATEX = "couleurLatex";
private static final String MOIS_POUSSE_TOT = "moisPousseTot";
private static final String MOIS_POUSSE_TARD = "moisPousseTard";
private static final String MILIEU = "milieu";
private static final String POUSSE_BOIS = "pousseBois";
private static final String NOM_VERNACULAIRE = "nomVernaculaire";
private static final String COMESTIBILITE = "comestibilite";
private static final String COMMENTAIRES = "commentaires";
private static final String SYNONYMES = "synonymes";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
getReadableDatabase();
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase)
//Création de la table champignon
String CREATE_CHAMPIGNON_TABLE = "create table if not exists " + TABLE_CHAMPIGNON + " ("
+ CHAMP_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + CHAMP_NAME + " VARCHAR (40),"
+ CHAMP_DIAMETRE_MIN + " INTEGER (2)," + CHAMP_DIAMETRE_MAX + " VARCHAR(3) ," + COULEUR_CHAPEAU + " VARCHAR (30)," + FORME_CHAPEAU + " VARCHAR (70),"
+ SURFACE_CHAPEAU + " VARCHAR (105)," + TYPE_MARGE + " VARCHAR (101)," + COULEUR_MARGE + " VARCHAR (11)," + DESSOUS_CHAPEAU + " VARCHAR (26),"
+ COULEUR_DESSOUS_CHAPEAU + " VARCHAR (29)," + OXYDATION_CHAPEAU + " VARCHAR(20)," + COULEUR_OXYDATION_CHAPEAU + " VARCHAR(14)," + INSERTION_DESSOUS_PIED + " VARCHAR (46),"
+ ESPACE_LAMELLES + " VARCHAR (8)," + TYPE_LAMELLES + " VARCHAR (34)," + COULEUR_PIED + " VARCHAR (22)," + PIED_CREUX_PLEIN + " VARCHAR (21),"
+ FORME_PIED + " VARCHAR (165)," + LONGEUR_PIED + " VARCHAR (10)," + SURFACE_PIED + " VARCHAR (84)," + POSITION_PIED_CHAPEAU + " VARCHAR (9),"
+ PRESENCE_ANNEAU + " VARCHAR (3)," + ORIENTATION_ANNEAU + " VARCHAR (10)," + MOBILITE_ANNEAU + " VARCHAR (6)," + COULEUR_ANNEAU + " VARCHAR (43),"
+ POUSSE_TOUFFE + " VARCHAR (3),"+ COULEUR_BASE_PIED + " VARCHAR (21)," + COULEUR_CHAIR + " VARCHAR (30)," + OXYDATION_CHAIR + " VARCHAR (3),"
+ COULEUR_OXYDATION_CHAIR + " VARCHAR (21)," + FERMETE_CHAIR + " VARCHAR (16)," + ODEUR + " VARCHAR (25)," + LATEX + " VARCHAR (3)," + COULEUR_LATEX + " VARCHAR (14),"
+ MOIS_POUSSE_TOT + " VARCHAR (19)," + MOIS_POUSSE_TARD + " VARCHAR (20)," + MILIEU + " VARCHAR (49)," + POUSSE_BOIS + " VARCHAR (3)," + NOM_VERNACULAIRE + " VARCHAR (87),"
+ COMESTIBILITE + " VARCHAR (18)," + COMMENTAIRES + " VARCHAR (332)," + SYNONYMES + " VARCHAR (34) )";
sqLiteDatabase.execSQL(CREATE_CHAMPIGNON_TABLE);
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_DIDACTICIEL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_LEAFS);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_ANIMAL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_CHAMPIGNON);
onCreate(sqLiteDatabase);
public void addChampignon (Mushroom champignon)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(CHAMP_NAME, champignon.getName());
values.put(CHAMP_DIAMETRE_MIN, champignon.getDiametreMin());
values.put(CHAMP_DIAMETRE_MAX, champignon.getDiametreMax());
values.put(COULEUR_CHAPEAU, champignon.getCouleurChapeau());
values.put(FORME_CHAPEAU, champignon.getFormeChapeau());
values.put(SURFACE_CHAPEAU, champignon.getSurfaceChapeau());
values.put(TYPE_MARGE, champignon.getTypeMarge());
values.put(COULEUR_MARGE, champignon.getCouleurMarge());
values.put(DESSOUS_CHAPEAU, champignon.getDessousChapeau());
values.put(COULEUR_DESSOUS_CHAPEAU,champignon.getCouleurDessousChapeau());
values.put(OXYDATION_CHAPEAU, champignon.getOxydationChapeau());
values.put(COULEUR_OXYDATION_CHAPEAU, champignon.getCouleurOxydationChapeau());
values.put(INSERTION_DESSOUS_PIED, champignon.getInsertionDessousPied());
values.put(ESPACE_LAMELLES, champignon.getEspaceLamelles());
values.put(TYPE_LAMELLES, champignon.getTypeLamelles());
values.put(COULEUR_PIED, champignon.getCouleurPied());
values.put(PIED_CREUX_PLEIN, champignon.getPiedCreuxPlein());
values.put(FORME_PIED, champignon.getFormePied());
values.put(LONGEUR_PIED, champignon.getLongueurPied());
values.put(SURFACE_PIED, champignon.getSurfacePied());
values.put(POSITION_PIED_CHAPEAU, champignon.getPositionPiedChapeau());
values.put(PRESENCE_ANNEAU, champignon.getPresenceAnneau());
values.put(ORIENTATION_ANNEAU, champignon.getOrientationAnneau());
values.put(MOBILITE_ANNEAU, champignon.getMobiliteAnneau());
values.put(COULEUR_ANNEAU, champignon.getCouleurAnneau());
values.put(POUSSE_TOUFFE, champignon.getPousseTouffe());
values.put(COULEUR_BASE_PIED, champignon.getCouleurBasePied());
values.put(COULEUR_CHAIR, champignon.getCouleurChair());
values.put(OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(COULEUR_OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(FERMETE_CHAIR, champignon.getFermeteChair());
values.put(ODEUR, champignon.getOdeur());
values.put(LATEX, champignon.getLatex());
values.put(COULEUR_LATEX, champignon.getCouleurLatex());
values.put(MOIS_POUSSE_TOT, champignon.getMoisPousseTot());
values.put(MOIS_POUSSE_TARD, champignon.getMoisPousseTard());
values.put(MILIEU, champignon.getMilieu());
values.put(POUSSE_BOIS, champignon.getPousseBois());
values.put(NOM_VERNACULAIRE, champignon.getNomVernaculaire());
values.put(COMESTIBILITE, champignon.getComestibilite());
values.put(COMMENTAIRES, champignon.getCommentaires());
values.put(SYNONYMES, champignon.getSynonymes());
db.insert(TABLE_CHAMPIGNON, null, values);
db.close();
/**
* Retourne une liste des champignons correspondant à la requête
*
* @param query
* @return
*/
public List<Mushroom> getChampignonFromRequest(String query)
List<Mushroom> mushroomList = new ArrayList<Mushroom>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
mushroomList.add(champ);
while (cursor.moveToNext());
cursor.close();
return mushroomList;
/**
* Ajout des Champignons depuis& un CSV
*
* @param inputStream
* @param context
*/
public void addChampignonFromCsv(InputStream inputStream, Context context)
DatabaseHandler db = new DatabaseHandler(context);
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine())
String line = scanner.nextLine();
String str[] = line.split(";");
db.addChampignon(new Mushroom(Integer.parseInt(str[0]), str[1], Integer.parseInt(str[2]), Integer.parseInt(str[3]),str[4],str[5],
str[6],str[7],str[8],str[9],str[10],str[11],str[12],str[13],str[14],str[15],
str[16],str[17],str[18],str[19],str[20],str[21],str[22],str[23],str[24],str[25],
str[26],str[27],str[28],str[29],str[30],str[31],str[32],str[33],str[34],str[35],
str[36],str[37],str[38],str[39],str[40],str[41],str[42]));
scanner.close();
/**
* Retourne tous les champignons de la base de données
*
* @return
*/
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
java sql
5
The tablebddchampignons
doesn't exist in the database
– XtremeBaumer
Mar 27 at 15:06
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
What doesgetReadableDatabase()
do?
– XtremeBaumer
Mar 28 at 7:07
add a comment |
My application crashes when I do a SQL request.
It says that the table doesn't exist and I don't know why.
Could you help me?
Here is the logcat:
03-27 15:35:49.718 5672-5672/descartes.info.l3ag2.eyetrek E/AndroidRuntime: FATAL EXCEPTION: main
Process: descartes.info.l3ag2.eyetrek,
PID: 5672 android.database.sqlite.SQLiteException: no such table: bddchampignons (code 1):,
while compiling: SELECT * FROM bddchampignons
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at descartes.info.l3ag2.eyetrek.classes.DatabaseHandler.getAllChampignons(DatabaseHandler.java:578)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1.lambda$onCreateView$2$FragmentCirconstance1(FragmentCirconstance1.java:147)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1$$Lambda$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
this is the request I am doing :
List<Mushroom> MushroomList = new ArrayList<Mushroom>();
MushroomList = databaseHandler.getAllChampignons();
String res= "";
Log.e("List", MushroomList.toString());
for (Mushroom mushroom: MushroomList)
Log.e("NAME", mushroom.getName());
res = res + mushroom.getId() + "n";
createAlertBox("Resultats", res);
and this is a part of the code from my DataBaseHandler class where is the method getAllChampignons
:
private static final String TABLE_CHAMPIGNON = "bddchampignons";
//(my csv file is named "bddchampignons")
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
this is my DataBaseHandler classe where I created my table, but it doesn't work ..
I'm just showing you the part where it's about champignons(mushrooms)
and you can find :
- method onCreate where the table champignons is created
- method to create an Mushroom Object
- method which return a list with the elements corresponding to the SQL request
- method which return a list with all the elements of the database
- method
public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "db_eyetrek";
private static final String TABLE_CHAMPIGNON = "bddchampignons";
private static final String CHAMP_ID = "id";
private static final String CHAMP_NAME = "name";
private static final String CHAMP_DIAMETRE_MIN = "diametreMin";
private static final String CHAMP_DIAMETRE_MAX = "diametreMax";
private static final String COULEUR_CHAPEAU = "couleurChapeau";
private static final String FORME_CHAPEAU = "formeChapeau";
private static final String SURFACE_CHAPEAU = "surfaceChapeau";
private static final String TYPE_MARGE= "typeMarge";
private static final String COULEUR_MARGE = "couleurMarge";
private static final String DESSOUS_CHAPEAU = "dessousChapeau";
private static final String COULEUR_DESSOUS_CHAPEAU = "couleurDessousChapeau";
private static final String OXYDATION_CHAPEAU = "oxydationChapeau";
private static final String COULEUR_OXYDATION_CHAPEAU = "couleurOxydationChapeau";
private static final String INSERTION_DESSOUS_PIED= "insertionDessousPied";
private static final String ESPACE_LAMELLES = "espaceLamelles";
private static final String TYPE_LAMELLES = "typeLamelles";
private static final String COULEUR_PIED = "couleurPied";
private static final String PIED_CREUX_PLEIN = "piedCreuxPlein";
private static final String FORME_PIED = "formePied";
private static final String LONGEUR_PIED = "longueurPied";
private static final String SURFACE_PIED = "surfacePied";
private static final String POSITION_PIED_CHAPEAU = "positionPiedChapeau";
private static final String PRESENCE_ANNEAU = "presenceAnneau";
private static final String ORIENTATION_ANNEAU = "orientationAnneau";
private static final String MOBILITE_ANNEAU = "mobiliteAnneau";
private static final String COULEUR_ANNEAU = "couleurAnneau";
private static final String POUSSE_TOUFFE = "pousseTouffe";
private static final String COULEUR_BASE_PIED = "couleurBasePied";
private static final String COULEUR_CHAIR = "couleurChair";
private static final String OXYDATION_CHAIR = "oxydationChair";
private static final String COULEUR_OXYDATION_CHAIR = "couleurOxydationChair";
private static final String FERMETE_CHAIR = "fermeteChair";
private static final String ODEUR = "odeur";
private static final String LATEX = "latex";
private static final String COULEUR_LATEX = "couleurLatex";
private static final String MOIS_POUSSE_TOT = "moisPousseTot";
private static final String MOIS_POUSSE_TARD = "moisPousseTard";
private static final String MILIEU = "milieu";
private static final String POUSSE_BOIS = "pousseBois";
private static final String NOM_VERNACULAIRE = "nomVernaculaire";
private static final String COMESTIBILITE = "comestibilite";
private static final String COMMENTAIRES = "commentaires";
private static final String SYNONYMES = "synonymes";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
getReadableDatabase();
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase)
//Création de la table champignon
String CREATE_CHAMPIGNON_TABLE = "create table if not exists " + TABLE_CHAMPIGNON + " ("
+ CHAMP_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + CHAMP_NAME + " VARCHAR (40),"
+ CHAMP_DIAMETRE_MIN + " INTEGER (2)," + CHAMP_DIAMETRE_MAX + " VARCHAR(3) ," + COULEUR_CHAPEAU + " VARCHAR (30)," + FORME_CHAPEAU + " VARCHAR (70),"
+ SURFACE_CHAPEAU + " VARCHAR (105)," + TYPE_MARGE + " VARCHAR (101)," + COULEUR_MARGE + " VARCHAR (11)," + DESSOUS_CHAPEAU + " VARCHAR (26),"
+ COULEUR_DESSOUS_CHAPEAU + " VARCHAR (29)," + OXYDATION_CHAPEAU + " VARCHAR(20)," + COULEUR_OXYDATION_CHAPEAU + " VARCHAR(14)," + INSERTION_DESSOUS_PIED + " VARCHAR (46),"
+ ESPACE_LAMELLES + " VARCHAR (8)," + TYPE_LAMELLES + " VARCHAR (34)," + COULEUR_PIED + " VARCHAR (22)," + PIED_CREUX_PLEIN + " VARCHAR (21),"
+ FORME_PIED + " VARCHAR (165)," + LONGEUR_PIED + " VARCHAR (10)," + SURFACE_PIED + " VARCHAR (84)," + POSITION_PIED_CHAPEAU + " VARCHAR (9),"
+ PRESENCE_ANNEAU + " VARCHAR (3)," + ORIENTATION_ANNEAU + " VARCHAR (10)," + MOBILITE_ANNEAU + " VARCHAR (6)," + COULEUR_ANNEAU + " VARCHAR (43),"
+ POUSSE_TOUFFE + " VARCHAR (3),"+ COULEUR_BASE_PIED + " VARCHAR (21)," + COULEUR_CHAIR + " VARCHAR (30)," + OXYDATION_CHAIR + " VARCHAR (3),"
+ COULEUR_OXYDATION_CHAIR + " VARCHAR (21)," + FERMETE_CHAIR + " VARCHAR (16)," + ODEUR + " VARCHAR (25)," + LATEX + " VARCHAR (3)," + COULEUR_LATEX + " VARCHAR (14),"
+ MOIS_POUSSE_TOT + " VARCHAR (19)," + MOIS_POUSSE_TARD + " VARCHAR (20)," + MILIEU + " VARCHAR (49)," + POUSSE_BOIS + " VARCHAR (3)," + NOM_VERNACULAIRE + " VARCHAR (87),"
+ COMESTIBILITE + " VARCHAR (18)," + COMMENTAIRES + " VARCHAR (332)," + SYNONYMES + " VARCHAR (34) )";
sqLiteDatabase.execSQL(CREATE_CHAMPIGNON_TABLE);
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_DIDACTICIEL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_LEAFS);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_ANIMAL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_CHAMPIGNON);
onCreate(sqLiteDatabase);
public void addChampignon (Mushroom champignon)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(CHAMP_NAME, champignon.getName());
values.put(CHAMP_DIAMETRE_MIN, champignon.getDiametreMin());
values.put(CHAMP_DIAMETRE_MAX, champignon.getDiametreMax());
values.put(COULEUR_CHAPEAU, champignon.getCouleurChapeau());
values.put(FORME_CHAPEAU, champignon.getFormeChapeau());
values.put(SURFACE_CHAPEAU, champignon.getSurfaceChapeau());
values.put(TYPE_MARGE, champignon.getTypeMarge());
values.put(COULEUR_MARGE, champignon.getCouleurMarge());
values.put(DESSOUS_CHAPEAU, champignon.getDessousChapeau());
values.put(COULEUR_DESSOUS_CHAPEAU,champignon.getCouleurDessousChapeau());
values.put(OXYDATION_CHAPEAU, champignon.getOxydationChapeau());
values.put(COULEUR_OXYDATION_CHAPEAU, champignon.getCouleurOxydationChapeau());
values.put(INSERTION_DESSOUS_PIED, champignon.getInsertionDessousPied());
values.put(ESPACE_LAMELLES, champignon.getEspaceLamelles());
values.put(TYPE_LAMELLES, champignon.getTypeLamelles());
values.put(COULEUR_PIED, champignon.getCouleurPied());
values.put(PIED_CREUX_PLEIN, champignon.getPiedCreuxPlein());
values.put(FORME_PIED, champignon.getFormePied());
values.put(LONGEUR_PIED, champignon.getLongueurPied());
values.put(SURFACE_PIED, champignon.getSurfacePied());
values.put(POSITION_PIED_CHAPEAU, champignon.getPositionPiedChapeau());
values.put(PRESENCE_ANNEAU, champignon.getPresenceAnneau());
values.put(ORIENTATION_ANNEAU, champignon.getOrientationAnneau());
values.put(MOBILITE_ANNEAU, champignon.getMobiliteAnneau());
values.put(COULEUR_ANNEAU, champignon.getCouleurAnneau());
values.put(POUSSE_TOUFFE, champignon.getPousseTouffe());
values.put(COULEUR_BASE_PIED, champignon.getCouleurBasePied());
values.put(COULEUR_CHAIR, champignon.getCouleurChair());
values.put(OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(COULEUR_OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(FERMETE_CHAIR, champignon.getFermeteChair());
values.put(ODEUR, champignon.getOdeur());
values.put(LATEX, champignon.getLatex());
values.put(COULEUR_LATEX, champignon.getCouleurLatex());
values.put(MOIS_POUSSE_TOT, champignon.getMoisPousseTot());
values.put(MOIS_POUSSE_TARD, champignon.getMoisPousseTard());
values.put(MILIEU, champignon.getMilieu());
values.put(POUSSE_BOIS, champignon.getPousseBois());
values.put(NOM_VERNACULAIRE, champignon.getNomVernaculaire());
values.put(COMESTIBILITE, champignon.getComestibilite());
values.put(COMMENTAIRES, champignon.getCommentaires());
values.put(SYNONYMES, champignon.getSynonymes());
db.insert(TABLE_CHAMPIGNON, null, values);
db.close();
/**
* Retourne une liste des champignons correspondant à la requête
*
* @param query
* @return
*/
public List<Mushroom> getChampignonFromRequest(String query)
List<Mushroom> mushroomList = new ArrayList<Mushroom>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
mushroomList.add(champ);
while (cursor.moveToNext());
cursor.close();
return mushroomList;
/**
* Ajout des Champignons depuis& un CSV
*
* @param inputStream
* @param context
*/
public void addChampignonFromCsv(InputStream inputStream, Context context)
DatabaseHandler db = new DatabaseHandler(context);
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine())
String line = scanner.nextLine();
String str[] = line.split(";");
db.addChampignon(new Mushroom(Integer.parseInt(str[0]), str[1], Integer.parseInt(str[2]), Integer.parseInt(str[3]),str[4],str[5],
str[6],str[7],str[8],str[9],str[10],str[11],str[12],str[13],str[14],str[15],
str[16],str[17],str[18],str[19],str[20],str[21],str[22],str[23],str[24],str[25],
str[26],str[27],str[28],str[29],str[30],str[31],str[32],str[33],str[34],str[35],
str[36],str[37],str[38],str[39],str[40],str[41],str[42]));
scanner.close();
/**
* Retourne tous les champignons de la base de données
*
* @return
*/
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
java sql
My application crashes when I do a SQL request.
It says that the table doesn't exist and I don't know why.
Could you help me?
Here is the logcat:
03-27 15:35:49.718 5672-5672/descartes.info.l3ag2.eyetrek E/AndroidRuntime: FATAL EXCEPTION: main
Process: descartes.info.l3ag2.eyetrek,
PID: 5672 android.database.sqlite.SQLiteException: no such table: bddchampignons (code 1):,
while compiling: SELECT * FROM bddchampignons
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at descartes.info.l3ag2.eyetrek.classes.DatabaseHandler.getAllChampignons(DatabaseHandler.java:578)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1.lambda$onCreateView$2$FragmentCirconstance1(FragmentCirconstance1.java:147)
at descartes.info.l3ag2.eyetrek.fragment.mushroomanalysis.FragmentCirconstance1$$Lambda$2.onClick(Unknown Source)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
this is the request I am doing :
List<Mushroom> MushroomList = new ArrayList<Mushroom>();
MushroomList = databaseHandler.getAllChampignons();
String res= "";
Log.e("List", MushroomList.toString());
for (Mushroom mushroom: MushroomList)
Log.e("NAME", mushroom.getName());
res = res + mushroom.getId() + "n";
createAlertBox("Resultats", res);
and this is a part of the code from my DataBaseHandler class where is the method getAllChampignons
:
private static final String TABLE_CHAMPIGNON = "bddchampignons";
//(my csv file is named "bddchampignons")
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
this is my DataBaseHandler classe where I created my table, but it doesn't work ..
I'm just showing you the part where it's about champignons(mushrooms)
and you can find :
- method onCreate where the table champignons is created
- method to create an Mushroom Object
- method which return a list with the elements corresponding to the SQL request
- method which return a list with all the elements of the database
- method
public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "db_eyetrek";
private static final String TABLE_CHAMPIGNON = "bddchampignons";
private static final String CHAMP_ID = "id";
private static final String CHAMP_NAME = "name";
private static final String CHAMP_DIAMETRE_MIN = "diametreMin";
private static final String CHAMP_DIAMETRE_MAX = "diametreMax";
private static final String COULEUR_CHAPEAU = "couleurChapeau";
private static final String FORME_CHAPEAU = "formeChapeau";
private static final String SURFACE_CHAPEAU = "surfaceChapeau";
private static final String TYPE_MARGE= "typeMarge";
private static final String COULEUR_MARGE = "couleurMarge";
private static final String DESSOUS_CHAPEAU = "dessousChapeau";
private static final String COULEUR_DESSOUS_CHAPEAU = "couleurDessousChapeau";
private static final String OXYDATION_CHAPEAU = "oxydationChapeau";
private static final String COULEUR_OXYDATION_CHAPEAU = "couleurOxydationChapeau";
private static final String INSERTION_DESSOUS_PIED= "insertionDessousPied";
private static final String ESPACE_LAMELLES = "espaceLamelles";
private static final String TYPE_LAMELLES = "typeLamelles";
private static final String COULEUR_PIED = "couleurPied";
private static final String PIED_CREUX_PLEIN = "piedCreuxPlein";
private static final String FORME_PIED = "formePied";
private static final String LONGEUR_PIED = "longueurPied";
private static final String SURFACE_PIED = "surfacePied";
private static final String POSITION_PIED_CHAPEAU = "positionPiedChapeau";
private static final String PRESENCE_ANNEAU = "presenceAnneau";
private static final String ORIENTATION_ANNEAU = "orientationAnneau";
private static final String MOBILITE_ANNEAU = "mobiliteAnneau";
private static final String COULEUR_ANNEAU = "couleurAnneau";
private static final String POUSSE_TOUFFE = "pousseTouffe";
private static final String COULEUR_BASE_PIED = "couleurBasePied";
private static final String COULEUR_CHAIR = "couleurChair";
private static final String OXYDATION_CHAIR = "oxydationChair";
private static final String COULEUR_OXYDATION_CHAIR = "couleurOxydationChair";
private static final String FERMETE_CHAIR = "fermeteChair";
private static final String ODEUR = "odeur";
private static final String LATEX = "latex";
private static final String COULEUR_LATEX = "couleurLatex";
private static final String MOIS_POUSSE_TOT = "moisPousseTot";
private static final String MOIS_POUSSE_TARD = "moisPousseTard";
private static final String MILIEU = "milieu";
private static final String POUSSE_BOIS = "pousseBois";
private static final String NOM_VERNACULAIRE = "nomVernaculaire";
private static final String COMESTIBILITE = "comestibilite";
private static final String COMMENTAIRES = "commentaires";
private static final String SYNONYMES = "synonymes";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
getReadableDatabase();
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase)
//Création de la table champignon
String CREATE_CHAMPIGNON_TABLE = "create table if not exists " + TABLE_CHAMPIGNON + " ("
+ CHAMP_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + CHAMP_NAME + " VARCHAR (40),"
+ CHAMP_DIAMETRE_MIN + " INTEGER (2)," + CHAMP_DIAMETRE_MAX + " VARCHAR(3) ," + COULEUR_CHAPEAU + " VARCHAR (30)," + FORME_CHAPEAU + " VARCHAR (70),"
+ SURFACE_CHAPEAU + " VARCHAR (105)," + TYPE_MARGE + " VARCHAR (101)," + COULEUR_MARGE + " VARCHAR (11)," + DESSOUS_CHAPEAU + " VARCHAR (26),"
+ COULEUR_DESSOUS_CHAPEAU + " VARCHAR (29)," + OXYDATION_CHAPEAU + " VARCHAR(20)," + COULEUR_OXYDATION_CHAPEAU + " VARCHAR(14)," + INSERTION_DESSOUS_PIED + " VARCHAR (46),"
+ ESPACE_LAMELLES + " VARCHAR (8)," + TYPE_LAMELLES + " VARCHAR (34)," + COULEUR_PIED + " VARCHAR (22)," + PIED_CREUX_PLEIN + " VARCHAR (21),"
+ FORME_PIED + " VARCHAR (165)," + LONGEUR_PIED + " VARCHAR (10)," + SURFACE_PIED + " VARCHAR (84)," + POSITION_PIED_CHAPEAU + " VARCHAR (9),"
+ PRESENCE_ANNEAU + " VARCHAR (3)," + ORIENTATION_ANNEAU + " VARCHAR (10)," + MOBILITE_ANNEAU + " VARCHAR (6)," + COULEUR_ANNEAU + " VARCHAR (43),"
+ POUSSE_TOUFFE + " VARCHAR (3),"+ COULEUR_BASE_PIED + " VARCHAR (21)," + COULEUR_CHAIR + " VARCHAR (30)," + OXYDATION_CHAIR + " VARCHAR (3),"
+ COULEUR_OXYDATION_CHAIR + " VARCHAR (21)," + FERMETE_CHAIR + " VARCHAR (16)," + ODEUR + " VARCHAR (25)," + LATEX + " VARCHAR (3)," + COULEUR_LATEX + " VARCHAR (14),"
+ MOIS_POUSSE_TOT + " VARCHAR (19)," + MOIS_POUSSE_TARD + " VARCHAR (20)," + MILIEU + " VARCHAR (49)," + POUSSE_BOIS + " VARCHAR (3)," + NOM_VERNACULAIRE + " VARCHAR (87),"
+ COMESTIBILITE + " VARCHAR (18)," + COMMENTAIRES + " VARCHAR (332)," + SYNONYMES + " VARCHAR (34) )";
sqLiteDatabase.execSQL(CREATE_CHAMPIGNON_TABLE);
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion)
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_DIDACTICIEL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_LEAFS);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_ANIMAL);
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_CHAMPIGNON);
onCreate(sqLiteDatabase);
public void addChampignon (Mushroom champignon)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(CHAMP_NAME, champignon.getName());
values.put(CHAMP_DIAMETRE_MIN, champignon.getDiametreMin());
values.put(CHAMP_DIAMETRE_MAX, champignon.getDiametreMax());
values.put(COULEUR_CHAPEAU, champignon.getCouleurChapeau());
values.put(FORME_CHAPEAU, champignon.getFormeChapeau());
values.put(SURFACE_CHAPEAU, champignon.getSurfaceChapeau());
values.put(TYPE_MARGE, champignon.getTypeMarge());
values.put(COULEUR_MARGE, champignon.getCouleurMarge());
values.put(DESSOUS_CHAPEAU, champignon.getDessousChapeau());
values.put(COULEUR_DESSOUS_CHAPEAU,champignon.getCouleurDessousChapeau());
values.put(OXYDATION_CHAPEAU, champignon.getOxydationChapeau());
values.put(COULEUR_OXYDATION_CHAPEAU, champignon.getCouleurOxydationChapeau());
values.put(INSERTION_DESSOUS_PIED, champignon.getInsertionDessousPied());
values.put(ESPACE_LAMELLES, champignon.getEspaceLamelles());
values.put(TYPE_LAMELLES, champignon.getTypeLamelles());
values.put(COULEUR_PIED, champignon.getCouleurPied());
values.put(PIED_CREUX_PLEIN, champignon.getPiedCreuxPlein());
values.put(FORME_PIED, champignon.getFormePied());
values.put(LONGEUR_PIED, champignon.getLongueurPied());
values.put(SURFACE_PIED, champignon.getSurfacePied());
values.put(POSITION_PIED_CHAPEAU, champignon.getPositionPiedChapeau());
values.put(PRESENCE_ANNEAU, champignon.getPresenceAnneau());
values.put(ORIENTATION_ANNEAU, champignon.getOrientationAnneau());
values.put(MOBILITE_ANNEAU, champignon.getMobiliteAnneau());
values.put(COULEUR_ANNEAU, champignon.getCouleurAnneau());
values.put(POUSSE_TOUFFE, champignon.getPousseTouffe());
values.put(COULEUR_BASE_PIED, champignon.getCouleurBasePied());
values.put(COULEUR_CHAIR, champignon.getCouleurChair());
values.put(OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(COULEUR_OXYDATION_CHAIR, champignon.getCouleurOxydationChair());
values.put(FERMETE_CHAIR, champignon.getFermeteChair());
values.put(ODEUR, champignon.getOdeur());
values.put(LATEX, champignon.getLatex());
values.put(COULEUR_LATEX, champignon.getCouleurLatex());
values.put(MOIS_POUSSE_TOT, champignon.getMoisPousseTot());
values.put(MOIS_POUSSE_TARD, champignon.getMoisPousseTard());
values.put(MILIEU, champignon.getMilieu());
values.put(POUSSE_BOIS, champignon.getPousseBois());
values.put(NOM_VERNACULAIRE, champignon.getNomVernaculaire());
values.put(COMESTIBILITE, champignon.getComestibilite());
values.put(COMMENTAIRES, champignon.getCommentaires());
values.put(SYNONYMES, champignon.getSynonymes());
db.insert(TABLE_CHAMPIGNON, null, values);
db.close();
/**
* Retourne une liste des champignons correspondant à la requête
*
* @param query
* @return
*/
public List<Mushroom> getChampignonFromRequest(String query)
List<Mushroom> mushroomList = new ArrayList<Mushroom>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
mushroomList.add(champ);
while (cursor.moveToNext());
cursor.close();
return mushroomList;
/**
* Ajout des Champignons depuis& un CSV
*
* @param inputStream
* @param context
*/
public void addChampignonFromCsv(InputStream inputStream, Context context)
DatabaseHandler db = new DatabaseHandler(context);
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine())
String line = scanner.nextLine();
String str[] = line.split(";");
db.addChampignon(new Mushroom(Integer.parseInt(str[0]), str[1], Integer.parseInt(str[2]), Integer.parseInt(str[3]),str[4],str[5],
str[6],str[7],str[8],str[9],str[10],str[11],str[12],str[13],str[14],str[15],
str[16],str[17],str[18],str[19],str[20],str[21],str[22],str[23],str[24],str[25],
str[26],str[27],str[28],str[29],str[30],str[31],str[32],str[33],str[34],str[35],
str[36],str[37],str[38],str[39],str[40],str[41],str[42]));
scanner.close();
/**
* Retourne tous les champignons de la base de données
*
* @return
*/
public List<Mushroom> getAllChampignons()
List<Mushroom> champignonsList = new ArrayList<Mushroom>();
String selectQuery = "SELECT * FROM " + TABLE_CHAMPIGNON;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst())
do
Mushroom champ = new Mushroom();
champ.setId(Integer.parseInt(cursor.getString(0)));
champ.setName(cursor.getString(1));
champ.setDiametreMin(Integer.parseInt(cursor.getString(2)));
champ.setDiametreMax(Integer.parseInt(cursor.getString(3)));
champ.setCouleurChapeau(cursor.getString(4));
champ.setFormeChapeau(cursor.getString(5));
champ.setSurfaceChapeau(cursor.getString(6));
champ.setTypeMarge(cursor.getString(7));
champ.setCouleurMarge(cursor.getString(8));
champ.setDessousChapeau(cursor.getString(9));
champ.setCouleurDessousChapeau(cursor.getString(10));
champ.setOxydationChapeau(cursor.getString(11));
champ.setCouleurOxydationChapeau(cursor.getString(12));
champ.setInsertionDessousPied(cursor.getString(13));
champ.setEspaceLamelles(cursor.getString(14));
champ.setTypeLamelles(cursor.getString(15));
champ.setCouleurPied(cursor.getString(16));
champ.setPiedCreuxPlein(cursor.getString(17));
champ.setFormePied(cursor.getString(18));
champ.setLongueurPied(cursor.getString(19));
champ.setSurfacePied(cursor.getString(20));
champ.setPositionPiedChapeau(cursor.getString(21));
champ.setPresenceAnneau(cursor.getString(22));
champ.setOrientationAnneau(cursor.getString(23));
champ.setMobiliteAnneau(cursor.getString(24));
champ.setCouleurAnneau(cursor.getString(25));
champ.setPousseTouffe(cursor.getString(26));
champ.setCouleurBasePied(cursor.getString(27));
champ.setCouleurChair(cursor.getString(28));
champ.setOxydationChair(cursor.getString(29));
champ.setCouleurOxydationChair(cursor.getString(30));
champ.setFermeteChair(cursor.getString(31));
champ.setOdeur(cursor.getString(32));
champ.setLatex(cursor.getString(33));
champ.setCouleurLatex(cursor.getString(34));
champ.setMoisPousseTot(cursor.getString(35));
champ.setMoisPousseTard(cursor.getString(36));
champ.setMilieu(cursor.getString(37));
champ.setPousseBois(cursor.getString(38));
champ.setNomVernaculaire(cursor.getString(39));
champ.setComestibilite(cursor.getString(40));
champ.setCommentaires(cursor.getString(41));
champ.setSynonymes(cursor.getString(42));
champignonsList.add(champ);
while (cursor.moveToNext());
return champignonsList;
java sql
java sql
edited Mar 27 at 19:15
Lilemy C
asked Mar 27 at 15:05
Lilemy CLilemy C
94 bronze badges
94 bronze badges
5
The tablebddchampignons
doesn't exist in the database
– XtremeBaumer
Mar 27 at 15:06
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
What doesgetReadableDatabase()
do?
– XtremeBaumer
Mar 28 at 7:07
add a comment |
5
The tablebddchampignons
doesn't exist in the database
– XtremeBaumer
Mar 27 at 15:06
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
What doesgetReadableDatabase()
do?
– XtremeBaumer
Mar 28 at 7:07
5
5
The table
bddchampignons
doesn't exist in the database– XtremeBaumer
Mar 27 at 15:06
The table
bddchampignons
doesn't exist in the database– XtremeBaumer
Mar 27 at 15:06
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
What does
getReadableDatabase()
do?– XtremeBaumer
Mar 28 at 7:07
What does
getReadableDatabase()
do?– XtremeBaumer
Mar 28 at 7:07
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55380441%2fapplication-crashes-after-sql-request%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55380441%2fapplication-crashes-after-sql-request%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
The table
bddchampignons
doesn't exist in the database– XtremeBaumer
Mar 27 at 15:06
I added the databaseHandler class where I created the table, and still it does not work..
– Lilemy C
Mar 27 at 19:15
Try login to database and check for table using the ID that this program uses. It may be the table exists and the User ID is not granted permission.
– javapedia.net
Mar 27 at 19:20
What does
getReadableDatabase()
do?– XtremeBaumer
Mar 28 at 7:07