skip to Main Content

Android Studio – How to use sharedpref.edit() only once

I have a code where I called sharedPref.edit() and sharedPref.apply() multiple times. How to make convert it to call only once. if (success) { val data = response.getJSONObject("data") sharedPreferences.edit().putBoolean("isLoggedIn", true).apply() sharedPreferences.edit() .putString("user_id", data.getString("user_id")).apply() sharedPreferences.edit().putString("name", data.getString("name")) .apply() sharedPreferences.edit().putString("email", data.getString("email")) .apply() sharedPreferences.edit()…

VIEW QUESTION

Android Studio – How to return a result in ActivityResultLauncher

I'm using ZXing API. I have the following code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ IntentIntegrator integrator = new IntentIntegrator(activity); integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES); integrator.setCameraId(0); integrator.setOrientationLocked(true); integrator.setPrompt("Para usar o flash utilizar os botões do volume"); integrator.initiateScan(); However, I don't know how to…

VIEW QUESTION
Back To Top
Search