I've watched countless tutorials and examples about SQLite on Android but I just don't get some things. could someone please explain some things to me?
This the code that I came up with until now (SQLite helper):
public class SQLiteHelper extends SQLiteOpenHelper {
public static String DATABASE_NAME = "urnik";
public static int DATABASE_VERSION = 1;
public SQLiteHelper(Context context, String name, CursorFactory factory,
int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
//Tabela prva ura
public static String IME_TABELE = "prva_ura";
public static String ID_PREDMETA = "id_predmeta";
public static String NAZIV_PREDMETA = "naziv_predmeta";
String prva_query =
"CREATE TABLE " + IME_TABELE + " ("
+ ID_PREDMETA + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAZIV_PREDMETA + " TEXT" + ");";
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(prva_query);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
So as far as I know, this should create a new database and one table called "prva_ura". But I have a lot of questions about this.
I only created this class, I haven't attached it to MainActivity or anything, will the database still be created when app is ran for the first time or do I have to do something else?
I'm assuming the database is created when the app is launched for the first time after creating database. Can I find the database file anywhere to check if everything is as it's supposed to be?
I'd appreciate some tips in general, thank you!