Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)'.  on a null object reference.  i m getting this error please help.   private void loadSongs() {         Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;         String selection = MediaStore.Audio.Media.IS_MUSIC + "!=0";         Cursor cursor = getContext().getContentResolver().query(uri, null, selection, null, null);         if (cursor != null) {             if (cursor.moveToFirst()) {                 do {                      String name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));                     String artist = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));                     String url = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));                     String albumId = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));                     Cursor cursorm = getContext().getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,                             new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART},                             MediaStore.Audio.Albums._ID+ "=?",                             new String[] {String.valueOf(albumId)},                             null);                     assert cursorm != null;                     if (cursorm.moveToFirst()) {                         String path = cursorm.getString(cursorm.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));                         Drawable img = Drawable.createFromPath(path);                         image = (ImageView)rootView.findViewById(R.id.albumArt);                        // image.setImageDrawable(img);                         image.setImageDrawable(ContextCompat.getDrawable(getActivity(),R.drawable.ed));                     }                     songInfo s = new songInfo(name, artist, url);                     _songs.add(s);                 }                 while (cursor.moveToNext());                 cursor.close();                 recyclerView.getAdapter().notifyDataSetChanged();             }         }     }
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?
Checking if a key exists in a JavaScript object? Avoiding Mixed DML (setup/non-setup) Approach I need an approach to allow delegated admins (i.e., non-Administators) to add members to Public Groups and Collaboration Groups (the GroupMember and CollaborationGroupMember objects).  I added a custom object (UserGroupRequest__c) to capture which Users should be added/removed to which Groups.    I've also built a batchable class to process the requests.  However, GroupMember is a Setup object, and CollaborationGroupMember is not.  So this doesn't work if I combine the operations in a single batchable class.  Should I instead be using 2 batch classes, calling one from the finish method of the other?    Any recommendations on how best to proceed?  Am I way off base?    Would a trigger on the Request object perhaps be better? I'm guessing that there may be a permission problem if this is attempted via a trigger as the delegated admins won't be able to add users to public Groups.  Also, I'm guessing the trigger approach would run into the same mixed DML issue - on Insert of the Custom object, I would need to Insert/Delete from GroupMember and from CollaborationGroupMember, and then perform a 2nd update on the Custom object to indicate that processing was completed... How does gravity escape a black hole? How do I find out which process is eating up my bandwidth? I think I'm being the victim of a bug here. Sometimes while I'm working (I still don't know why), my network traffic goes up to 200 KB/s and stays that way, even tough I'm not doing anything internet-related.   This sometimes happens to me with the CPU usage. When it does, I just run a top command to find out which process is responsible and then kill it. Problem is: I have no way of knowing which process is responsible for my high network usage. Both the resource monitor and the top command only tell me my total network usage, neither of them tells me process specific network info.  I've found questions here about monitoring total bandwidth usage, but, as I mentioned, that's not what I need. Is there another command I can use to find out which process is getting out of hand?  The command iftop gives results that disagree entirely with the information reported by System Monitor. While the latter claims there's high network traffic, the former claims there's barely 1 KB/s.  I've already tried killing all the obvious ones (Firefox, update-manager, Pidgin, etc) with no luck. So far, restarting the machine is the only way I found of getting rid of the issue. Where can I find header files in C on unix Deferring admission to a computer science graduate program Lowering the throttling temperature in Windows 8 for a laptop List of blogs to learn more about Ubuntu Add blogs and websites that are useful in the quest to know/learn more about Ubuntu.  One blog per answer, please - you can vote answers up/down as you feel appropriate. If you feel the blog is biased towards or is good for particular tasks, please mention them. Why have header files and .cpp files? How do you correctly say large numbers It seems to me that tuples are just as elementary as sets. Can tuples be reduced to sets? Cardinality of set of real continuous functions What is a "callback" in C and how are they implemented? From the reading that I have done, Core Audio relies heavily on callbacks (and C++, but that's another story).    I understand the concept (sort of) of setting up a function that is called by another function repeatedly to accomplish a task.  I just don't understand how they get set up and how they actually work.  Any examples would be appreciated. What are the downsides of removing ubuntu-desktop metapackage? I once advised someone to remove a package that depends on ubuntu-desktop meta-package, if she didn't need it (EG: if one uses a different editor than gedit). Someone else said that doing so (removing gedit which will in turn remove ubuntu-desktop) could break things. Is this true? Are there any other potential problems? Can a dichotomous variable (yes/no) be merged with a Likert measure (1,2,3,4) using z scores? I added a new field on Opportunity table to keep a count of records, as well as track the updates made on that record.  This is needed for an external system we use. Opportinity table already has around 5000 records now. I would like to update the new field that I added with some sequence order initially. Say each record to have a unique sequence number like 1,2,3 etc(can't use the Id field for unique). The field "Identifier__c" was added for this purpose with data type number and unique contraint. For that I created a temporary class and trigger. But it is throwing the error.     Review all error messages below to correct your data. Apex trigger OpportunitySAPIdentifierHandler caused an unexpected exception,   contact your administrator: OpportunitySAPIdentifierHandler: execution   of BeforeUpdate caused by: System.DmlException: Update failed. First   exception on row 0 with id 006E00000038FPSIA2; first error:   CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunitySAPIdentifierHandler:   execution of BeforeUpdate caused by: System.DmlException: Update   failed. First exception on row 0 with id 006E00000038FPTIA2; first   error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,   OpportunitySAPIdentifierHandler: execution of BeforeUpdate caused by:   System.DmlException: Update failed. First exception on row 0 with id   006E00000038FPSIA2; first error: SELF_REFERENCE_FROM_TRIGGER, Object   (id = 006E00000038FPS) is currently in trigger   OpportunitySAPIdentifierHandler, therefore it cannot recursively   update itself: [] Class.AutoNumber.OpportunityAutoNumber: line 76,   column 1 Trigger.OpportunitySAPIdentifierHandler: line 4, column 1: []   Class.AutoNumber.OpportunityAutoNumber: line 76, column 1   Trigger.OpportunitySAPIdentifierHandler: line 4, column 1: []:   Class.AutoNumber.OpportunityAutoNumber: line 76, column 1   Below is the trigger and class used.  trigger Opportuniwith sIdentifierHandler on Opportunity (before insert,before update) {          If(Trigger.isInsert || Trigger.isUpdate){             AutoNumber.OpportunityAutoNumber(Trigger.new);         }   }   The class is   public with sharing class AutoNumber {       public static void OpportunityAutoNumber (List&lt;Opportunity&gt; Opp) {          if(Trigger.isUpdate || Trigger.isInsert) {              for(Opportunity p: Opp) {                  List&lt;Opportunity&gt; oppList = new List&lt;Opportunity&gt;();                 oppList = [SELECT Id, createdDate, Identifier__c FROM Opportunity where Identifier__c = null and Id != :p.Id limit 100 FOR update];                 for (Opportunity oppL: oppList) {                      if(oppL.Identifier__c == null) {                          List&lt;Opportunity&gt; OpportunityList = new List&lt;Opportunity&gt;([select Identifier__c from Opportunity where Identifier__c != null order by Identifier__c desc limit 1]);                          if (!OpportunityList.isEmpty()) {                               Decimal maxval = OpportunityList.get(0).Identifier__c;                             oppL.Identifier__c = maxval + 1;                             update oppL;                         }                      }                     // integer currentCounter = Integer.valueOf(opp.Identifier__c);                     // oppr.Identifier__c = currentCounter + 1;                     // update oppr;                 }             }         }        }  } Running two MySQL servers that use the same data directory Can people PLEASE spell out their slang acronyms I'm always on the hunt for free stock images to use while I design, what are some good resources for images that are under a a royalty free or creative commons licence? Combo box in Java - nullpointer