I have a conundrum, I do know how to call method from other activity.. crating object etc..
But I have dbHelper.java that deal with creating sql little tables etc and start like:
public class dbHelper extends SQLiteOpenHelper {
.
.
.
}
it works fine but i have method there that check when the DB version change and recreate DB tables etc..
like:
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// pri zmene verzie DB dropne tabulku
Log.w("DATA", "Upgrading database from version " + oldVersion + " to " + newVersion);
db.execSQL("DROP TABLE IF EXISTS plan");
db.execSQL("DROP TABLE IF EXISTS contacts");
this.onCreate(db);
}
but I need to store also shared preference that I use to tell application that its new start… however its kind of strange i try :
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCE_FILENAME,MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("FS", "1");
editor.commit();
But MODE_PRIVATE get underlined as error, even when I try call method from other activity creating object like this for example: dataManager db = new dataManager(this); where is method to store shared preference I get still underlined it as error…
Any idea what might be the issue ? I’m learning java but still no idea :-/
Vlad
MODE_PRIVATEis a constant which is declared inContextclass. Just changeMODE_PRIVATEtoContext.MODE_PRIVATEThis works fine inside the Activity’s method, cause’
Activityis a subclass ofContext