Search code examples
androiddropboxdropbox-api

android - upload pictures to dropbox


I am new to android programming. I am trying to upload pictures to dropbox, but I am getting java.lang.NullPointerException exception during the photo upload.

Here is my code snippet

try {
    FileInputStream fis = new FileInputStream(mFile);
    String path = mPath + mFile.getName();
    System.out.println("mFile is " + file);
    System.out.println("path is  " + path);
    System.out.println("fis is " + fis);
    mRequest = mdpi.putFileOverwriteRequest(path, fis, mFile.length(), null);
    if (mRequest != null) {
        mRequest.upload();

    }

The error is pointing me to this line mRequest = mdpi.putFileOverwriteRequest(path, fis, mFile.length(), null);

When i print out the variables which I am using in this line. I am getting the image path directory successfully, but don't know whats wrong.


Solution

  • You have forgotten to declare the mdpi and to instanciate it.