I am following this tutorial made by our folks over at Google.
If you look at the third code snippet, the tutorial shows the FeedReaderDbHelper class which extends from the SQLiteOpenHelper class.
public class FeedReaderDbHelper extends SQLiteOpenHelper
Then, it shows how to create an instance of the FeedReaderDbHelper object in order to use it to read and write to the database.
FeedReaderDbHelper mDbHelper = new FeedReaderDbHelper(getContext());
The problem as I see it is that SQLiteOpenHelper is an abstract class. So whenever I do the following in my own program:
MatchEntry.MatchDBHelper dbHelper = new MatchEntry.MatchDBHelper(context);
I get an error: ....MatchContract.MatchEntry is not an enclosing class
Is this because of SQLiteOpenHelper being abstract? The way I have set-up my classes are exactly the same and pretty much mimic exactly what the docs have.
Update
This is how the structure looks like so far:
public class MatchContract {
public MatchContract() {
}
public static abstract class MatchEntry implements BaseColumns {
...
...
...
}
public class MatchDBHelper extends SQLiteOpenHelper {
...
...
...
}
}
Am I correct to put the MatchDBHelper inside the MatchContract class? I assume so as it needs to know the SQL_CREATE_TABLE string, otherwise it won't know.
MatchDBHelpercan't be an inner class, I think. I also did that tutorial. Here you have it, take a look. You will see contract is separated from the sqlHelper class: github.com/algui91/CursoAndroid/tree/master/Ejemplos/…DBHelperfor every entry? For example:StudentDBHelper,ClassDBHelper,CarDBHelper?