I tried to change a SharedPreference that is set up in my MainActivity in my Adapter. So I thought with an instance of the MainActivity I could access and change it from there. When an item is clicked a dialog pops up and then when it is confirmed, the variable shall be stored in the SharedPreference. Unfortunately I get an error in the part where this variable should be edited:     android.content.SharedPreferences$Editor   android.content.SharedPreferences.edit()' on a null object reference   The MainActivity:  public class MainActivity extends AppCompatActivity {      SharedPreferences favE;     int x;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          favE = MainActivity.this.getSharedPreferences("myFavEName",                 Context.MODE_PRIVATE);         x = favE.getInt("favKey", 0);      }      public int getFavE(){         return x;     } }   My Adapter:  public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.ViewHolder&gt; {      Context context;      List&lt;GetDataAdapter&gt; getDataAdapter;      MainActivity ma = new MainActivity();      @Override     public void onBindViewHolder(ViewHolder holder, final int position) {          GetDataAdapter getDataAdapter1 =  getDataAdapter.get(position);          final int a = getDataAdapter1.getId();          int x = ma.getFavE();          holder.cardView.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View v) {                  addDialog(a);                });     }       public void addDialog(final int a) {         Context context = this.context;         LayoutInflater inflater = LayoutInflater.from(this.context);          AlertDialog.Builder builder = new AlertDialog.Builder(context);          builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {             public void onClick(DialogInterface dialog, int id) {              }         });          builder.setPositiveButton("Exit Group", new DialogInterface.OnClickListener() {             public void onClick(DialogInterface dialog, int id) {                           ma.favE.edit().putInt("favKey", 0)                         .apply();             }         });         builder.show();     } }
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Prime factorization of square numbers Let n be a natural number with unique prime factorization $p^m$... $q^k$ . Show that n can be written as a square if and only if  all (m, ...k) are even Find all functions $f$ such that $(x+y)f(x)+f(y^2)=(x+y)f(y)+f(x^2)$ Find all functions $f$ that assign a real number $f(x)$ to every real number $x$ such that $$(x+y)f(x)+f(y^2)=(x+y)f(y)+f(x^2)$$  I've tried subbing in heaps of values but I keep getting things like $f(0)=f(0)$ and other such useless results.  Any help would be hugely appreciated. How to make partitions mount at startup? How do you make HDDs and partitions mount at startup on Ubuntu?  I always keep my media and data files on separate partitions - one 2tb HDD and a 400 odd gig partition.  I have been trying to swap the default folder location for the home directory to my other drives.  It works when I change the /home/user_name/.config/user-dirs.dirs file to the directories I want, but only until I reboot the system. I am only assuming that the drives not mounting is the problem with it, but it would be helpful either way.  If any one knows another reason for why the directories change back to default each time that would be good also. I have an 3TB external disk and Windows XP 32 bit. It works as a USB 2 disk with its enclosure, but I want to use it as an internal SATA disk. I don't want to use it as a boot disk, only as a data disk. I understand that normally I need GPT (GUID partition table), and then I can't use Windows XP 32 bit anymore. I would prefer to avoid this. But what I did not understand by googling around is: can I partition the disk in 2 parts (so that each part is less than 2TB) with MBR and use it in Windows 32-bit? If yes, which tools do I need? symmetric functions vs symmetric polynomials I am doing my thesis related with symmetric functions and representations.   It is for this reason that I am reading MacDonald's book Symmetric Functions and Hall Polynomials.  When reading chapter 1.2. The ring of symmetric functions, he also talks about symmetric polynomials. And he compares both notions and sometimes treats them as equivalent but sometimes not. Does anyone have a clearer explanation about what is the difference (if there are differences)?  So, what is the difference between symmetric functions and symmetric polynomials? How does this wiring work? I have a Trane XV90 and XL 14i. The wiring looks a little strange as in the picture bellow.                    _____________                   |           |   BK W2  W1   R  G  Y  B/C  YLO O     |___||   |__|  ||   |          |   |     ||   |_____>|----------|         |   |     ||_________>|other wire|         |   |     |           ------------         V   V     V     ---------------     |thermostat   |     ---------------  The R and G are jumpered together and the G wire is connected on the board  but is actually not connecting to the thermostat on the other end. So people told me that means the furnace fan is always on! (In my diagram above, I switched the location of Y and B/C to make diagram easier to draw. You can refer to the photo added below to see the details) My questions are the following  is the jumper between O and Y doing anything? I don't think I have heat pump I need to install Honeywell wifi thermostat and I am thinking of doing either one of the following:   remove jumper between R and G, and use G to connect B/C and then to thermostat C and put jumper between G and Y  leave jumper between R and G, and use G to connect B/C and then to thermostat C and put jumper between G and Y  remove jumper between R and G, connect G on control board to thermostat G, and finally have the spare wire to connect B/C and then thermostat C  leave jumper between R and G, does not connect G to thermostat,  and just use a spare wire to connect B/C on board to thermostat C   Can anyone comment on those plans? Thanks a lot! Drop In Reputation - But No Record Of Why? youtube-dl failed to extract signature It is considered very useful to utilize youtube-dl software for downloading youtubes.  A message is seen and it stopped working, which is following.  ERROR: Signature extraction failed: Traceback (most recent call last):   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 479, in _decrypt_signature     video_id, player_url, s   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 383, in _extract_signature_function     res = self._parse_sig_js(code)   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 454, in _parse_sig_js     u'Initial JS player signature function name')   File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 391, in _search_regex     raise RegexNotFoundError(u'Unable to extract %s' % _name) RegexNotFoundError: Unable to extract Initial JS player signature function name; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update. ; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.   What should I do to proceed? Suppose you have 2 circles that intersect each other in such a way that each circle passes through the other's center. What is the area between the circle(or common area) i.e. area between the centres of the circles? problems installing mathtools There have been a few questions regarding installing this package in the past, but they now seem to be out of date. I'm using MiKTeX 2.9 and TexMaker. When I try \usepackage{mathtools} in TexMaker it will try to install the package for me but will fail. I took the advice given in this thread:   As suggested I tried installing the mh package using the MiKTeX Package Manager, unfortunately I get the "unknown archive size" error, which I have read means that the package no longer exists. Another thread (lost the link) said you can use the MiKTeX Package Manager to directly install mathtools, however I do not see mathtools listed anywhere in the MiKTeX Package Manager...   So I ask, is the package under a different name? Are there any other ways to install this package? I want to prove that in an infinite dimensional normed space $X$, the weak closure of the unit sphere $S=\{ x\in X : \| x \| = 1 \}$ is the unit ball $B=\{ x\in X : \| x \| \leq 1 \}$.  $\\$  Here is my attempt with what I know:  I know that the weak closure of $S$ is a subset of $B$ because $B$ is norm closed and convex, so it is weakly closed, and $B$ contains $S$.  But I need to show that $B$ is a subset of the weak closure of $S$.  $\\$  for small $\epsilon &gt; 0$, and some $x^*_1,...,x^*_n \in X^*$, I let $U=\{ x : \langle x, x^*_i \rangle &lt; \epsilon , i = 1,...,n \} $  then $U$ is a weak neighbourhood of $0$  What I think I need to show now is that $U$ intersects $S$, but I don't know how. If the $n^{th}$ partial sum of a series $\sum a_n$ is $S_n = \dfrac{n-1}{n+1}$, find $a_n$ and the sum.  By definition,  the sum of the series is the $\lim n\to\infty$ of it's $n^{th}$ partial sum.  $$\text{ Sum = } \lim_{n\to\infty} = \dfrac{n-1}{n+1} = 1$$  I am asked to find $a_n$. How do I do this? What is the procedure? How can we close questions with bounties? I just encountered , which is very cute and funny and has nothing to do with programming.  I tried voting to close, but was informed by the system that I can't do that when there's a bounty on the question.  So, since there's a seven-day bounty, this will remain open for at least a week.  I really don't care what happens to the bounty rep, I just want to be able to close questions that are thoroughly inappropriate although not offensive. I have a Word file which has some Excel plots in it. Unfortunately I lost the original excel plots and the word file is now 'de-linked'.   Is there a way to retrieve the lost data for the plots? Just copying the plot back to Excel does not seem to work, but I can see that the data is still there somewhere, because hovering over a dot on the plot shows the values. When watching US television news or reading US news articles there is this affectation where instead of saying:     "Spotify music-streaming service to launch in U.S. on Thursday" ()   or      "Leading credit rating agency Moody's said on Wednesday that the U.S. government's impeccable credit..." ()   The on preposition is missed out.  Is this just a peculiar US journalistic "news speak" shortcut or do American non-journalist writers write this way too? Search for ,        ,                        and you will see that "results found containing __" is just a little too close to the header. It's not like there isn't  to have it be a little lower, closer to "Search":          The UI has been updated since I took the above screenshots, and the text you search for is  (which fixes another design issue but not the one in this question): Yesterday, I've listened to a song called "Fear not this night". I find the syntax unusual (as a foreigner, I have never encountered it). Is it the same meaning as "Don't fear this night" ? What's the slight difference between these 2 ?  Thank you for your time. Seeking alternatives to pgRouting for open source routing / network analysis? I was wondering if there are any alternatives to  tools.  Thinking about it for a bit, I think the only alternative is to use R or RPY to do the analysis.   Basically I'm trying to solve routing problems based on nonPostGIS databases. As most of my data is actually stored in a different format; however, it's not to hard to convert. I'm finding that pgRouting to my dumb silly brain is difficult to implement. So perhaps a non-database solution that I can easily tweak would be ideal for me What do we mean by hyperparameters? Can anyone give me full details about what we mean by hyperparameters, and what in the Dirichlet distribution are called hyperparameters? A practice example for the estimation of those parameters would also be useful. Where do I find the client id and client secret of an existing connected app?