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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:55:50+00:00 2026-05-30T08:55:50+00:00

I am working on an application in which i need to save table data

  • 0

I am working on an application in which i need to save table data as an image when the user clicks on a button. To do so I used the following code:

//save is the button to click
this.save.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        AlertDialog.Builder alert=new AlertDialog.Builder(MyActivity.this);
        alert.setTitle("Save");
        alert.setMessage("Enter a file name");        
        final EditText input=new EditText(MyActivity.this);
        alert.setView(input);         
        alert.setPositiveButton("OK", new DialogInterface.OnClickListener(){
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                table.setDrawingCacheEnabled(true); 
                Bitmap b=table.getDrawingCache();
                Bitmap combo=Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ARGB_8888);
                Canvas canvas=new Canvas(combo);
                canvas.drawBitmap(b, 0f, 175f, null);               
                OutputStream outStream = null;
                String value=input.getText().toString();
                File directory =new File(extStorageDirectory+"/Files/");
                if(!directory.mkdir())
                    directory.mkdir();
                File file = new File(directory, value);
                try {
                    outStream = new FileOutputStream(file);
                    combo.compress(Bitmap.CompressFormat.PNG, 100, outStream);
                    FileOutputStream fOut=openFileOutput("public.dat", Context.MODE_PRIVATE|Context.MODE_APPEND);
                    OutputStreamWriter osw=new OutputStreamWriter(fOut);
                                osw.write(value+"\n");                          
                    osw.flush();
                    osw.close();
                    fOut.flush();
                    fOut.close();
                    outStream.flush();
                    outStream.close();                                              
                } catch (FileNotFoundException e) {                     
                    e.printStackTrace();                    
                } catch (IOException e) {                       
                    e.printStackTrace();                    
                }
            }               
        });

This function saves an image with no problem but when i change my table and try to save another image it saves the first one. I think i need to reset the canvas or something like that so I tried the following after saving the file:

  canvas.restore();

But it doesn’t work. But wheh i relaunch the application on the simulator i can save a new image. Can someone please help me solve 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-05-30T08:55:51+00:00Added an answer on May 30, 2026 at 8:55 am

    I found the solution to my problem. I just had to add

    table.destroyDrawingCache();
    

    just before catching exceptions.

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

Sidebar

Related Questions

Working on a small web application, I have a user table in which user
Hello Everyone, I am working on an application in which i need to save
I'm working on an asp.net application which uses Lucene.net I need to highlight the
I'm working on an application which stores data in tables, similar to an RDBMS.
I'm working on an application which has data imported from a foreign (and wholly
Am working on an application which has a requirement to download bulk data from
I have a working JNLP application which I need to distribute to various non-technical
I am working in an application where we need to save objects in XML
As the title suggests im working with a Core Data Application which gets filled
I am working on application which is currently for Phones only...but I need to

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.