i Can't Create My DataBase With SqliteOpenHelper.My OnCreate Method Don't Run at all
i have already tried getReadable and getWriteable DataBase Methods but nothing Changes
public class SQLiteHandler extends SQLiteOpenHelper {
private static SQLiteHandler sInstance;
private static final String DATABASE_NAME = "telestaDB";
private static final int DATABASE_VERSION = 1;
private static final String TAG = "SqliteHelper";
public SQLiteHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
getReadableDatabase();
getWritableDatabase();
Log.i(TAG, "Constractor create!!");
}
public static SQLiteHandler getInstance(Context context) {
if (sInstance == null) {
Log.i(TAG, "getInstance: new instance created!!");
sInstance = new SQLiteHandler(context.getApplicationContext());
}
return sInstance;
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL(ExceptionsModel.CREATE_TABLE);
sqLiteDatabase.execSQL(DownloadModel.CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
/*
*
* @Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(ExceptionsModel.CREATE_TABLE);
Log.d(TAG, "onCreate: databaseCreated!!");
db.execSQL(DownloadModel.CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(ExceptionsModel.CREATE_TABLE);
Log.d(TAG, "onUpgrade: databaseCreated!!");
db.execSQL(DownloadModel.CREATE_TABLE);
}
}
nothing happens when i tried to create an object of helper class and try to insert data into that. i use these lines to create db
SQLiteHandler sqliteHelper = SQLiteHandler.getInstance(context);
sqliteHelper.getWritableDatabase();
i already seen some other questions about this problem but no one helped!