I am using fire base to store the images in that i am getting a error in storage Ref unable to resolve the symbol please help.
public class Sample extends Activity {
public static final String GridViewDemo_ImagePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pencilrulerlearner/";
StorageReference riversRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
File targetDirector = new File(GridViewDemo_ImagePath);
File[] files = targetDirector.listFiles();
for (File file1 : files) {
Uri file= Uri.fromFile(file1);
storageRef.child("images/" + file.getLastPathSegment());
UploadTask uploadTask = riversRef.putFile(file);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL.
Uri downloadUrl = taskSnapshot.getDownloadUrl();
}
});
}
}
}
Even i changed the storageRef to riversRef where i am getting the following error
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.storage.StorageReference com.google.firebase.storage.StorageReference.child(java.lang.String)' on a null object reference
at nidhinkumar.firebaseexample.Sample.onCreate(Sample.java:31)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)