Note that there are some explanatory texts on larger screens.

plurals
  1. POmethod is undefined issue
    text
    copied!<p>i worked on a sqlite tutorial and i thought it was clear but i have a problem. I want to create and read a db but there is an error in my code. I just started with android and java so i need some help with this.</p> <p>i have used wedstrijdgeschiedenis:</p> <pre><code>package com.justus.referee; public class WedstrijdenGeschiedenis { private int id; private String thuisclub; private String bezoekers; public WedstrijdenGeschiedenis(){} public WedstrijdenGeschiedenis(String thuisclub, String bezoekers) { super(); this.thuisclub = thuisclub; this.bezoekers = bezoekers; } //getters &amp; setters @Override public String toString() { return "Wedstrijd [id=" + id + ", thuis=" + thuisclub + ", Bezoekers=" + bezoekers + "]"; } } </code></pre> <p>and i use MySqLiteHelper:</p> <pre><code>package com.justus.referee; import java.util.LinkedList; import java.util.List; import com.justus.referee.WedstrijdenGeschiedenis; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper { // Database Version private static final int DATABASE_VERSION = 1; // Database Name private static final String DATABASE_NAME = "WedstrijdenDB"; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { // SQL statement to create wedstrijdenGeschiedenis table String CREATE_WEDSTRIJD_TABLE = "CREATE TABLE wedstrijden ( " + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "thuisclub TEXT, "+ "bezoekers TEXT )"; // create wedstrijdenGeschiedeniss table db.execSQL(CREATE_WEDSTRIJD_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // Drop older wedstrijdenGeschiedeniss table if existed db.execSQL("DROP TABLE IF EXISTS wedstrijden"); // create fresh wedstrijdenGeschiedeniss table this.onCreate(db); } //--------------------------------------------------------------------- /** * CRUD operations (create "add", read "get", update, delete) */ // WedstrijdenGeschiedeniss table name private static final String TABLE_WEDSTRIJD = "wedstrijden"; // WedstrijdenGeschiedeniss Table Columns names private static final String KEY_ID = "id"; private static final String KEY_THUIS = "thuisclub"; private static final String KEY_BEZOEKER = "bezoekers"; private static final String[] COLUMNS = {KEY_ID,KEY_THUIS,KEY_BEZOEKER}; public void addWedstrijd(WedstrijdenGeschiedenis wedstrijd){ Log.d("addWedstrijd", wedstrijd.toString()); // 1. get reference to writable DB SQLiteDatabase db = this.getWritableDatabase(); // 2. create ContentValues to add key "column"/value ContentValues values = new ContentValues(); values.put(KEY_THUIS, wedstrijd.getThuis()); // get thuis values.put(KEY_BEZOEKER, wedstrijd.getBezoeker()); // get bezoeker // 3. insert db.insert(TABLE_WEDSTRIJD, // table null, //nullColumnHack values); // key/value -&gt; keys = column names/ values = column values // 4. close db.close(); } </code></pre> <p>but in my eclipse there are three errors in this part of the code:</p> <pre><code>// 2. create ContentValues to add key "column"/value ContentValues values = new ContentValues(); values.put(KEY_THUIS, wedstrijd.getThuis()); // get thuis values.put(KEY_BEZOEKER, wedstrijd.getBezoeker()); // get bezoeker </code></pre> <p>the error is "<strong><em>the method getThuis() is undefined for the type WedstrijdenGeschiedenis</em></strong>"</p> <p>And i can't find the reason of this error. Sorry for the newbie problem!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

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

Reload