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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:42:07+00:00 2026-05-26T14:42:07+00:00

I have written a bit of code that when the listview is clicked, the

  • 0

I have written a bit of code that when the listview is clicked, the image at that location is stored to external memory, then the file path string is sent with the intent to view the image in the default gallery. The only problem is that it takes a seriously long amount of time (I’m talking 10+ seconds on my thunderbolt).

What I haved tried:
1. Storing the bitmap on internal memory
2. Lowering the quality of the bitmap

Here is the code:

@Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                    if(position>0){
                        Bitmap bmp =adapter.getBitmap(adapter.getData(position-1));
                        if(bmp!=null){
                            //String path = context.getCacheDir().getAbsolutePath() + "/view.png"; 
                            //File f = new File(context.getCacheDir().getAbsolutePath(),"MemeCache");
                            //if(!f.exists())
                            //    f.mkdirs();
                            String path = android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/view.png"; 
                            Toast.makeText(context, "opening in gallery", Toast.LENGTH_SHORT).show();
                            File file = new File(path); 
                            FileOutputStream fos = null;
                            try {
                                fos = new FileOutputStream(file);
                                bmp.compress(CompressFormat.PNG, 100, fos ); 
                                fos.close(); 
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            Intent intent = new Intent();
                            intent.setAction(android.content.Intent.ACTION_VIEW);
                            intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
                            //intent.setDataAndType(Uri.fromFile(f), "image/png");
                            activity.startActivity(intent);
                        }else{
                            Toast.makeText(context, arg0.getItemAtPosition(position).toString() +"is HaAAACkSS!!!!", Toast.LENGTH_SHORT).show();
                        }
                    }
                }
            });
  • 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-26T14:42:08+00:00Added an answer on May 26, 2026 at 2:42 pm

    Some things that might help:

    1) add some timers or instrumentation to you code to see exactly where you’re spending all the time: saving the bitmap to the sdcard, starting the intent, or something else entirely.

    2) Once you’ve added timers and can measure the performance, you can see if shrinking the image or storing the image in a different place helps and if so how much. On some devices, internal storage is on the sdcard itself.

    3) depending on your program, you might want to consider pre-saving the files to the sdcard (possibly in the background) so that they are probably already saved by the time the user tries to view them in the gallery.

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

Sidebar

Related Questions

I have some old code written in C for 16-bit using Borland C++ that
I have written a bit of code that helps with versioning of js files.
I have a bit of Java code that outputs an XML file to a
I have written a bit of code to match two vector of objects that
I have just been re-working an old bit of compiler-like code written using bison.
I've written a bit of code to upload a file to a server. When
I have written some C++ code that generates a std::vector. I also have a
I've written a bit of code in JavaScript that uses the window.navigator.language and the
I have my code that reads and writes to a serial port written in
I have written a standalone Java application that I've packaged into a jar file

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.