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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:00:01+00:00 2026-06-08T18:00:01+00:00

I have an image coded as base64 String, and I want to pass it

  • 0

I have an image coded as base64 String, and I want to pass it in another activity,
Due to the size limit of extra in the Intent, I have used this code to store it in a temp file

FileOutputStream fos;
        try {
            fos = openFileOutput(imagefilename, Context.MODE_PRIVATE);
            try {
                fos.write(encodedPhoto.getBytes());
                fos.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

And I have passed the imagefilename in another activity,

In the new Activity I have used this code to read it

try {
                FileInputStream fis = openFileInput(imagefilename);
                String strLine = null;
                StringBuffer buffer = new StringBuffer();
                DataInputStream dataIO = new DataInputStream(fis);

                if ((strLine = dataIO.readLine()) != null) {
                    buffer.append(strLine);
                }

                dataIO.close();
                fis.close();
                encodedPhoto = strLine;
            } catch (NullPointerException e) {

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

However in this way I cannot read correctly the original encoded Base64 photo…

I don’t get any error however the String of the encoded image(encodedPhoto) read, seems corrupted

How I can fix this problem?

  • 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-08T18:00:03+00:00Added an answer on June 8, 2026 at 6:00 pm

    Your read method is wrong,

    Try to use this code:

    try {
                    FileInputStream fis = openFileInput(imagefilename);
                    String line = null;
                    StringBuilder buffer = new StringBuilder();
                    BufferedReader reader = new BufferedReader(
                            new InputStreamReader(fis));
    
                    while ((line = reader.readLine()) != null) {
                        buffer.append(line);
                    }
    
                    fis.close();
                    encodedPhoto = buffer.toString();
                } catch (NullPointerException e) {
    
                } catch (IOException e) {
                    e.printStackTrace();
                }
    

    In this way you can read the String content of the file without modification.

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

Sidebar

Related Questions

I have the following code that is hard coded <img src=data:image/png;base64,iVBORw0KGgoAAAANSUh .... > Through
I have at base64 encoded string of a image file. I need to save
I have a Base64 String that represents a BitMap image. I need to transform
If I have a string in the form: data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAA2UlEQVQ4y8WSvQvCMBDFX2rFUvuFSAUFBQfBwUXQVfFfFpzdRV2c7O5UKmihX9E6RZo2pXbyTbmX3C+5uwD/FskG+76WsvX65n/3Lm0pdU214HOAbHIWwvzeYPL1p4cT4QCi5DIxEINIdWt+Hs9cXAtg3UOkIJAUpT5ADiho8kbD0NG0LB6Q76xIevwCpW+0bBvj7Y5wgCpI148RBxTmYo7Z1RGPkSk/kc4jgme0oHoJlmFUOC+8lUEMN0ASvyBpGha++IXCJrJyKJGhjIalyZVyNqufP9j/9AH0S0vqrU+YMgAAAABJRU5ErkJggg== What is the best regex
I have an image saved by another code of mine. The image is a
I want to replace Demo image by code css3 or somthing else. I have
I have an application, currently written in C#, which can take a Base64-encoded string
I have a base64 string and i need to show it in my IE
I have some problem for decoding image data from base 64 encoded string. I
image is the string of an image file . I have code as follows

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.