Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:12:41+00:00 2026-06-06T04:12:41+00:00

I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in

  • 0

I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in my code below. I have no idea why am I getting this error. Please help me how can I solve this problem.

Here is my code

here is the method in which this error occurs

public boolean fileData(String guid, String photoName) {
    Toast.makeText(getApplicationContext(), photoName, Toast.LENGTH_LONG).show();

    JSONObject json = userFunctions.uploadFileData(guid, photoName);

    try {
        if(Integer.parseInt(json.getString("success")) != 1) {
            Toast.makeText(getApplicationContext(), json.getInt("error_msg"), Toast.LENGTH_LONG).show();
            //register_error.setText(json.getString("error_msg"));
            return false;
        }
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return true;
}

Here is my uploadedFileData method

public JSONObject uploadFileData(String uid, String photoName) {
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("tag", file_tag));
    params.add(new BasicNameValuePair("uid", uid));
    params.add(new BasicNameValuePair("photoName", photoName));
    JSONObject json = jsonParser.getJSONFromUrl(url, params);
    Log.e("Some",json.toString());
    return json;
}

and here is my JSONParser class

public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

public JSONParser() {

}

public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) {

    try {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(new UrlEncodedFormEntity(params));

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
        String line = null;

        while((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }

        is.close();
        json = sb.toString();
        //Log.e("JSON", json);
    } catch (Exception e) {
        //e.printStackTrace();
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
    }

    return jObj;
}
}

Here is my logcat

06-16 17:03:47.890: E/AndroidRuntime(12364): FATAL EXCEPTION: main
06-16 17:03:47.890: E/AndroidRuntime(12364): java.lang.NullPointerException
06-16 17:03:47.890: E/AndroidRuntime(12364):    at com.zafar.login.Camera.fileData(Camera.java:216)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at com.zafar.login.Camera$2.run(Camera.java:186)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at android.os.Handler.handleCallback(Handler.java:587)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at android.os.Handler.dispatchMessage(Handler.java:92)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at android.os.Looper.loop(Looper.java:130)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at android.app.ActivityThread.main(ActivityThread.java:3691)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at java.lang.reflect.Method.invokeNative(Native Method)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at java.lang.reflect.Method.invoke(Method.java:507)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
06-16 17:03:47.890: E/AndroidRuntime(12364):    at dalvik.system.NativeStart.main(Native Method)
06-16 17:03:55.115: I/Process(12364): Sending signal. PID: 12364 SIG: 9
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:12:42+00:00Added an answer on June 6, 2026 at 4:12 am

    as in Exception stack trace userFunctions is last function (in your application) so as per code userFunctions may be null because json can’t be reason because you are using json.toString() in uploadFileData but trace is not till there…..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this java.lang.NullPointerException on the line where mLoginButton's onClickListener is initiated. I
I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I keep getting this error 07-14 23:53:03.653: ERROR/AndroidRuntime(14995): java.lang.NullPointerException 07-14 23:53:03.653: ERROR/AndroidRuntime(14995): at com.fttech.organizeit.meeting_list$meetingHolder.populateFrom(meeting_list.java:110)
i keep getting NullPointerException on this line: SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this); i ran some
I have a about screen that has some buttons, but I keep getting NullPointerException
I keep getting the same vague error with this code: command.CommandText = INSERT INTO
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting a 'List does not exist' error whenever I try and use
I keep getting a -> Program received signal: EXC_BAD_ACCESS. In the following code but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.