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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:11:01+00:00 2026-06-10T07:11:01+00:00

this doesn’t always happen so i can’t understand properly what’s going on: my application

  • 0

this doesn’t always happen so i can’t understand properly what’s going on: my application take and modify a picture, then save it in external storage. If i try to open in the application a new saved pictures FROM A FILE MANAGER AND NOT FROM GALLERY, it crashes when executing cursor.getCount(), in DDMS i read the error:”cursor not closed before finally” this is the piece of code where the problem is, i can post more if necessary, thank you!
ps this code is taken from other answers here in stackoverflow, as you could expect i’m not an expert so please be patient with me, thanks
pps i can’t see immediatly images in gallery after saving it, when they appear in gallery this error desappear.

public static int getOrientation(Context context, Uri photoUri) {
        /* it's on the external media. */
        Cursor cursor = context.getContentResolver().query(photoUri,
                new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);


        if (cursor.getCount() != 1) { //HERE IS THE PROBLEM
            return -1;
        }

        cursor.moveToFirst();
        return cursor.getInt(0);
    }
  • 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-10T07:11:02+00:00Added an answer on June 10, 2026 at 7:11 am

    You can use the

    if(cursor.moveToFirst()) 
    {
        //Your code here
    }
    

    instead off

    cursor.getCount() 
    

    it will return true if cursor size is greater then 0 else it will return false……..so you can write like this………

    if (!cursor.moveToFirst())
       return -1;
    
    else 
       return 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This doesn't happen all the time. A bug is not a bug if cannot
This doesn't seem to happen automatically when using a text area , but does
This doesn't work. Can anyone tell why? #include <iostream> using namespace std; int mean(
This doesn't seem to work: func = getProductListings; params = {'user_id':1234,'short':true}; window.opener[func](params); can someone
This doesn't work but I can't see why it wouldn't? any help people? :)
Sorry if this doesn't make any sence, but I'm trying my best to understand
This doesn't work: int number = 1; String numberstring = IntToString(number); I get The
This doesn't seem to be causing an issue as yet, but it's something I
This doesn't compile, but what I'm trying to do is simply casting object to
This doesn't make sense to me, but I have a feeling I saw a

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.