sharedpreferences

Correct context to use in RecyclerView adapter

戏子无情 提交于 2020-02-25 13:14:34
问题 Which context should I be using when I use a SharedPreference within a RecyclerView adapter? This is confusing as when during the default one, context in val mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) appears as an unresolved reference. class MyRVAdapter(private val myString: ArrayList<String>): RecyclerView.Adapter<MyRVAdapter.MyViewHolder>() { private val typeA = 1 private val typeB = 2 override fun onCreateViewHolder(parent: ViewGroup, type: Int):

Android Pushing Updates on Play Store

☆樱花仙子☆ 提交于 2020-02-23 09:17:31
问题 I have an app that depends on SQLite for data which is populated by xmls shipped with the app in the assets folder. When you run the app the first time it sets a shared preference config_run = false. then i check if config_run = false then parse the xml and dump the data into db set config_run = true Now i realize that when i have to push an update on Google Play and add more content into the XML. Even though i change the database version from 1 to 2. The import script wont run because shared

FutureBuilder snapshot Data does not return anything , Why?

不打扰是莪最后的温柔 提交于 2020-02-06 09:53:57
问题 Trying to get stored data by SharedPreferences But does not work .. my main.dart : Widget build(BuildContext context) { return StreamProvider<User>.value( value: AuthService().user, child: FutureBuilder<String>( future: SaadConstants.setValueFromLocal('app_lang','ar'), builder: (BuildContext context, AsyncSnapshot<String> snapshot){ return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body:Wrapper(), ), ); } ), ); } my wrapper : @override Widget build(BuildContext context) {

FutureBuilder snapshot Data does not return anything , Why?

拈花ヽ惹草 提交于 2020-02-06 09:53:11
问题 Trying to get stored data by SharedPreferences But does not work .. my main.dart : Widget build(BuildContext context) { return StreamProvider<User>.value( value: AuthService().user, child: FutureBuilder<String>( future: SaadConstants.setValueFromLocal('app_lang','ar'), builder: (BuildContext context, AsyncSnapshot<String> snapshot){ return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body:Wrapper(), ), ); } ), ); } my wrapper : @override Widget build(BuildContext context) {

Android SharedPreferences Boolean not working

雨燕双飞 提交于 2020-02-05 06:32:08
问题 I'm trying to get a boolean value from SharedPreferences that is true but I'm getting a false value every time. The SharedPreferences file named "MyPref"contains the following code: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <boolean name="PREMIUM" value="true" /> </map> I'm adding values to SharedPreferences in MyActivity.class using the following code: SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 1); // 0 - for private mode Editor

SharedPreferences save a text entered in an EditText and display it in a TextView in another activity

有些话、适合烂在心里 提交于 2020-02-02 13:56:53
问题 I'm beginner in Android development and I have an issue with save changement with some texts display in some TextViews. But one is more difficult for me. For explain simple, I have 2 activities, Activity1 is the main, Activity2 is the user informations. In Activity1 (Main) the user clic the button ("login") then he go on Activity2 here user can enter his personal informations and he click on a button ("save data") then I add his datas on a database (SQLite), then when the user click on

Storing public key in sharedPreferences, and Retrieving it

谁说胖子不能爱 提交于 2020-01-31 04:03:09
问题 I am trying to use encrypt data using RSA. So far everything is fine. I can generate Private-Public keys, I can encrypt and Decrypt string successfully. Now i want stored Public key in SharedPreference. I can store it as string. I can retrieve it as string. I need to convert it to Key, to pass to cipher. Conversion from String to original format is not happening. This is what i tried KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); //generate key using RSA KeyPair

java.lang.NullPointerException on setOnClickListener in Fragment

余生长醉 提交于 2020-01-30 11:36:51
问题 I'm pretty new to Android and I'm trying to create an application that will score matches of the Vex Robotics Competition. I have a ViewPager with fragments for each team and i have a lot of buttons that increase and decrease numbers in EditTexts . I created an OnClickListener for each one. This code was working before I introduced SharedPreferences to carry values to the activity that calculates the score. Fragment Code (sorry, there's a lot of it): package com.bearsandthings

java.lang.NullPointerException on setOnClickListener in Fragment

 ̄綄美尐妖づ 提交于 2020-01-30 11:36:09
问题 I'm pretty new to Android and I'm trying to create an application that will score matches of the Vex Robotics Competition. I have a ViewPager with fragments for each team and i have a lot of buttons that increase and decrease numbers in EditTexts . I created an OnClickListener for each one. This code was working before I introduced SharedPreferences to carry values to the activity that calculates the score. Fragment Code (sorry, there's a lot of it): package com.bearsandthings

Save SWITCH button state, and recover state with SharedPrefs

我的梦境 提交于 2020-01-30 03:27:10
问题 I have a Settings class so the user can decide to subscribe/unsubscribe to channels in Parse Push. I think I got it all figure out except for the part to recover, and maintain the switch state next time user open the app or changes the state. Can someone please help me on how to save the state, and switch the SWITCH to what the user selected? public class Settings extends Activity { /** * Called when the activity is first created. */ private Switch krspush, egspush; public static final String