I want to check if the table has rows and if it contains, then I want to delete it. Below is my code for checking if table has rows in it.       boolean empty = true;     Cursor cursor = db.rawQuery("SELECT count(*) FROM TABLE_NAME",null);     cursor.moveToFirst();     if (cursor.getInt(0) &gt; 0)     {         empty = false;     }     else     {         empty= true;     }     return  empty;    I even tried checking with below code,      boolean empty = true;     Cursor cur = db.rawQuery("SELECT COUNT(*) FROM TABLE_NAME", null);     if (cur != null &amp;&amp; cur.moveToFirst()) {         empty = (cur.getInt (0) == 0);     }     cur.close();      return empty;       Both of the above code, throws NullPointerException in line  ("SELECT COUNT(*) FROM TABLE_NAME", null);  Any help would be great !! Thanks
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?
When I run LaTeX file its gives error as  "! Package minted Error: You must have pygmentize installed to use this package", you must have pygments installed. when I go through minted documentation minted itself required pygments, so Tex friend How do I install this pygment, I don't know the procedure to install. Please guid me or any link pygement.exe file ls command operating differently depending on recipient How does commands like ls know what its stdout is?  It seems ls is operating different depending on what the target stdout is. For example if I do:  ls /home/matt/tmp    the result is:  a.txt b.txt c.txt   However if I do  ls /home/matt/tmp | cat   the result is (i.e. new line per result):  a.txt b.txt c.txt   The process is passed a file descriptor 1 for stdout right? How does it determine how to format the result? Does the file descriptor reveal information? The  says that there is a moderator election occurring.   How does the election work and how can I get involved? Can mobs go through doors? I was wondering if mobs can go through doors or not. It's the difference between me just putting up a door to my house, or putting up dirt instead. Command to open a URL Is there a command I can use in Bash that will open a specific URL in the default browser? Using sed with an integer variable I want to sed using a variable.  For example, sed -n '1,10p' file. So, instead of 10, I want to use $k where k is an integer. How do I expire a PHP session after 30 minutes? I need to keep a session alive for 30 minutes and then destroy it. In the sentence: "Drinking and driving IS dangerous", why does the verb "to be" need to be singular? In the sentence: "Drinking and driving is dangerous". Drinking and driving are both subjects and the word dangerous is the object (I think) but why do I have to use the verb to be in singular? Change email login to another id My original email id got compromised and now I want my new email id to be the main id for all SE sites . How to delete original id from the system as someone else might login from it ? What are the difference between:    the action $\int_{t_{1}}^{t_{2}}(L+H) dt$ that we use in the principle of least action, and  the action integral $\int_{t_{1}}^{t_{2}}L dt$ that we use in Hamilton's variational principle?   References:   H. Goldstein, Classical Mechanics, Section 8.6. H. Goldstein, Classical Mechanics, Chapter 2. I don't know what I've done, but all of a sudden I am unable to compile any document which uses the geometry package. Minimal (non)-working example:     \documentclass[11pt]{article}      \usepackage{geometry}  \begin{document} test \end{document}   doesn't produce any output, and this is what I see in my error summary screen in TeXnicCenter:    The red arrow points to what seems to be the problem: something about the bundle "oberdiek" and its package "ifvtex" is causing pdflatex.exe (which, while I don't really know what it does, sounds pretty important) to "not be initialized". I , and it's relevance here is a mystery to me.  I've confirmed that all of my files without the geometry package compile just fine; however, that doesn't mean that the problem is with the geometry package - what seems more likely is that there is some hidden cause of the error, and geometry happens to be one way to induce that. By the way, I've tried compiling a document which includes the ifpdf and ifvtex packages separately, and they do just fine; it's only when I include the geometry package (which for some reason requires these ifpdf and ifvtex packages) that the error occurs.  I've tried the only things I can think of:   going into MiKTeX Package Manager (by the way I am using 2.8), and removing + reinstalling both geometry and oberdiek refreshing the file name database ("FNDB") deleting all automatically generated files, as well as simply starting over in a new document   So I'm stuck now. I've considered attempting to just get rid of all traces of MiKTeX and TeXnicCenter from my computer and starting over, but that seems a bit excessive - after all, the geometry package was working for me . I honestly am not sure what I did to cause this; I've spent today trying to make a better template file for myself, and so I've been trying out new packages, but if I'm not loading these new packages there shouldn't be any conflicts, right?   Actually, I've just now thought of something that I think I did between the last time it worked and now, so is a possible candidate for the cause: I had to install some package manually, as it wasn't available on MiKTeX, and so I created a folder and pointed MiKTeX to it (i.e. the second option ). The package didn't do what I wanted, so I deleted the folder and removed it from the list of folders I told MiKTeX to check. Perhaps it's still trying to reach it for some reason? I noticed that, for each research project, there comes a point where I have to consult the literature, and find all the previous research related to the current project.  Unfortunately, I seem to be very inefficient in my approach. I spend a lot of time digging through papers that are really interesting, but only of tangential importance to my current work, just to find the few papers that actually do similar things. (The pile of "cool paper, read when time" just keeps growing.)  Hence, I'm wondering: What is the most time efficient way to get a thorough overview of the literature in a specific niche of a field?    While searching for an answer I came across these questions:   - This question is quite similar and I liked the approach. I debated with myself if this is a duplicate, but I think it is focused more on how to be sure the search was exhaustive, whereas I'm worried about time efficiency. (Also, I'm a bit curious if things have changed since 2012.)   - The answer provides tips on how to identify what literature generally is important in a field, but I am looking for the most cost effective (least time consuming) way to do it in an area, where I know the broad literature, but not the specifics. I know as a fact that I've gotten liquids larger than 3 ounces through the TSA scanner systems (such as sunscreen). I was scolded one time for bringing a shampoo container, but I was still ultimately allowed to bring that container through.  In any case, how often are liquids larger than 3 ounces ultimately confisticated, if I put them in a ziploc bag where they can be clearly seen? Age from Date of Birth using JQuery I need to calculate if someone is over 18 from their date of birth using JQuery.  var curr = new Date(); curr.setFullYear(curr.getFullYear() - 18);  var dob = Date.parse($(this).text());  if((curr-dob)&lt;0) {     $(this).text("Under 18"); } else {     $(this).text(" Over 18"); }   There must be some easier functions to use to compare dates rather than using the setFullYear and getFullYear methods.  Note: My actual reason for wanting to find a new method is length of the code. I have to fit this code into a database field that is limited to 250 chars. Changing the database is not something that can happen quickly or easily. Combination proof for $n(n+1)2^{n-2}=\sum_{k=1}^{n}k^2\binom{n}{k}$ How can I show that   let $n$ and $k$ be integers.  $n(n+1)2^{n-2}=\sum_{k=1}^{n}k^2\dbinom{n}{k}$  It seems a bit confusing to me on the left hand side. You have a set of $n$ people on a team and you keep picking $k$ people who will play a match and you pick before that a captain $k^2$. How do I calculate rotation caused by bounce friction? How can we run a command stored in a variable? I've installed reCAPTCHA module but spam still bypass my security and leave nasty comments. What should I do? How to block them? SingleEmailMessage sending isn't working when called from Unit Test I have the following code:      public class OrderRequestCreationEmails {     public static void sendMail()     {          Messaging.reserveSingleEmailCapacity(2);         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();         String[] toAddresses = new String[] {'dgriff@varonis.com'};           mail.setToAddresses(toAddresses);          mail.setReplyTo('dgriff@varonis.com');          mail.setSenderDisplayName('Mail Test');          mail.setSubject('Success! Mail Sent');          mail.setBccSender(false);         mail.setPlainTextBody('BODY');          Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });     } }   I tried to call this function from a test as such: (I know its not an actual test, its just to see if I receive a mail).  @isTest private class CreationEmailsTest {     @isTest private static void sendMailTest() {         OrderRequestCreationEmails.sendMail();     } }   And I haven't received the mail, no idea why?  It's an example I took from the salesforce developer guide. couldn't find any answers online...  FYI - deliverability in the sandbox is turned on, and test deliverability works Why can't I buy the Windhelm house (Hjerim)? I've finished the Stormcloak storyline, and now cannot become a Thane of Windhelm without buying Hjerim. The Steward keeps saying something has happened and he can't sell it right now.  What the heck am I missing? I've been doing every random little quest from people in town I can find, hoping to unlock the house. I'm well over the 5/5 requirement of helping people.  Any ideas?