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 7574115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:21:19+00:00 2026-05-30T16:21:19+00:00

I have posted this problem yesterday..but unfortunately, no one has given me the solution

  • 0

I have posted this problem yesterday..but unfortunately, no one has given me the solution and I still dont know where my mistake is.

I just want to save the path of an image taken by the camera into a SQLite table. And afetr that I want ot retrieve this path from the database and display the picture.

Code:

public void takePic() {
    String fileName = "temp.jpg";  
    ContentValues values = new ContentValues();  
    values.put(MediaStore.Images.Media.TITLE, fileName);  
    mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  

    cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
    startActivityForResult(cameraIntent, Camera_requestCode);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Camera_requestCode && resultCode == RESULT_OK) {
        String[] projection = { MediaStore.Images.Media.DATA}; 
        Cursor cursor = managedQuery(mCapturedImageURI, projection, null, null, null); 
        int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
        cursor.moveToFirst(); 
        String capturedImageFilePath = cursor.getString(column_index_data);

        insertPath(capturedImageFilePath);
        Bitmap image = (Bitmap) data.getExtras().get("data");
    }
};

Logcat:

03-02 13:20:06.479: E/AndroidRuntime(378): FATAL EXCEPTION: main

03-02 13:20:06.479: E/AndroidRuntime(378): java.lang.RuntimeException: Unable to resume activity {com.android.SaveCameraPictureDemo/com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.android.SaveCameraPictureDemo/com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity}: java.lang.NullPointerException
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2832)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.access$1600(ActivityThread.java:117)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.os.Looper.loop(Looper.java:130)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-02 13:20:06.479: E/AndroidRuntime(378): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 13:20:06.479: E/AndroidRuntime(378): at java.lang.reflect.Method.invoke(Method.java:507)
03-02 13:20:06.479: E/AndroidRuntime(378): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-02 13:20:06.479: E/AndroidRuntime(378): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-02 13:20:06.479: E/AndroidRuntime(378): at dalvik.system.NativeStart.main(Native Method)
03-02 13:20:06.479: E/AndroidRuntime(378): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.android.SaveCameraPictureDemo/com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity}: java.lang.NullPointerException
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2107)
03-02 13:20:06.479: E/AndroidRuntime(378): … 13 more
03-02 13:20:06.479: E/AndroidRuntime(378): Caused by: java.lang.NullPointerException
03-02 13:20:06.479: E/AndroidRuntime(378): at android.content.ContentResolver.acquireProvider(ContentResolver.java:743)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.content.ContentResolver.query(ContentResolver.java:256)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.Activity.managedQuery(Activity.java:1550)
03-02 13:20:06.479: E/AndroidRuntime(378): at com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity.onActivityResult(SaveCameraPictureDemoActivity.java:67)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
03-02 13:20:06.479: E/AndroidRuntime(378): at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
03-02 13:20:06.479: E/AndroidRuntime(378): … 14 more
03-02 13:36:55.168: E/AndroidRuntime(434): FATAL EXCEPTION: main
03-02 13:36:55.168: E/AndroidRuntime(434): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.android.SaveCameraPictureDemo/com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity}: java.lang.NullPointerException
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2574)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread.access$2000(ActivityThread.java:117)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.os.Looper.loop(Looper.java:130)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-02 13:36:55.168: E/AndroidRuntime(434): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 13:36:55.168: E/AndroidRuntime(434): at java.lang.reflect.Method.invoke(Method.java:507)
03-02 13:36:55.168: E/AndroidRuntime(434): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-02 13:36:55.168: E/AndroidRuntime(434): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-02 13:36:55.168: E/AndroidRuntime(434): at dalvik.system.NativeStart.main(Native Method)
03-02 13:36:55.168: E/AndroidRuntime(434): Caused by: java.lang.NullPointerException
03-02 13:36:55.168: E/AndroidRuntime(434): at com.android.SaveCameraPictureDemo.SaveCameraPictureDemoActivity.onActivityResult(SaveCameraPictureDemoActivity.java:73)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
03-02 13:36:55.168: E/AndroidRuntime(434): at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
03-02 13:36:55.168: E/AndroidRuntime(434): … 11 more

  • 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-05-30T16:21:21+00:00Added an answer on May 30, 2026 at 4:21 pm

    Change your code,

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == Camera_requestCode && resultCode == RESULT_OK) {
    
           if(data != null)
           {
            String[] projection = { MediaStore.Images.Media.DATA}; 
            Cursor cursor = managedQuery(mCapturedImageURI, projection, null, null, null); 
            int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
            cursor.moveToFirst(); 
            String capturedImageFilePath = cursor.getString(column_index_data);
    
            insertPath(capturedImageFilePath);
            Bitmap image = (Bitmap) data.getExtras().get("data");
          }
         else
         {
           Log.e("OnActivityResult()", "data is null");
         }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've posted about this problem before, but I still haven't found a solution so
I have already posted a question about this, but the situation has changed sufficiently
Update I have posted my solution to this problem as an answer below. It
Similar to the question I posted yesterday , I have this problem that I
I have already posted my this problem another time but i have not got
I've posted this on django-users but haven't received a reply! So I have my
Ok, I have code that is working (posted after this) but before I expand
I have a question about this question . I posted a reply there but
This should be really simple, but I have tried many solutions posted on the
I have posted this yesterday, I didn't get the the answers that could solve

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.