hello im very new to coding in android studio so here is the scenario i have this user that logs in then i get his username i need to store the user's username because i needed to use it on the other pages in my project so what i did was do something like this
public user getLOGusr(String uname, String pass)
{
SQLiteDatabase db = this.getReadableDatabase();
String select = "SELECT uid, username, email FROM " + TABLE_USRS + " WHERE " + KEY_NAME + " = ? AND " + KEY_PASS + " = ?";
Cursor cursor = db.rawQuery(select, new String[]{uname, pass});
user usr = new user();
if(cursor != null && cursor.moveToFirst())
{
cursor.moveToFirst();
usr.setUsrid(Integer.parseInt(cursor.getString(0)));
usr.setuName(cursor.getString(1));
usr.seteAddress(cursor.getString(2));
PreferenceManager pm = PreferenceManager.getDefaultSharedPrefs(this);
SharedPreferences.Editor edit = pm.edit();
edit.putString("usrnm", cursor.getString(1));
edit.commit();
cursor.close();
}
else
{
usr = null;
}
return usr;
}
this is the function inside my dbhandler the problem is on the .getDefaultSharedPrefs
part and the .edit()
saying cannot resolve method the stuff im only trying to do is put the username into a session any help? thanks so much in advancve!