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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:14:43+00:00 2026-05-28T11:14:43+00:00

if (action.equals(saveToGallery)) { JSONObject obj = args.getJSONObject(0); String imageSource = obj.has(imageSrc) ? obj.getString(imageSrc) :

  • 0
 if (action.equals("saveToGallery")) {

                        JSONObject obj = args.getJSONObject(0);
                        String imageSource = obj.has("imageSrc") ? obj.getString("imageSrc") : null;
                        String imageName = obj.has("imageName") ? obj.getString("imageName") : null;
                        String savedImgSrc = saveImageToGallery(imageSource, imageName);
                        Log.v("SAve To Gallery ", "saved file url:  " + savedImgSrc);

                        return new PluginResult(PluginResult.Status.OK);
                    }
                    return new PluginResult(PluginResult.Status.INVALID_ACTION);
                } catch (JSONException e) {
                    e.printStackTrace();
                    return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
                }

public String saveImageToGallery(String imgSrc, String imgName) {
        Log.v("Save To Gallery ", "image SRc:  " + imgSrc + " , image Name:"
                + imgName);

        Context ctx = this.ctx;
        AssetManager assmgr = ctx.getAssets();
        File tempDir = new File("/sdcard/HarmonyDayApp/wallpapers/");
        tempDir.mkdirs();
        File file = new File(tempDir, imgName);
        try {
            InputStream is = null;
            is = assmgr.open("www/" + imgSrc);
            OutputStream os = new FileOutputStream(file);
            byte[] data = new byte[is.available()];
            is.read(data);
            os.write(data);
            sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+Environment.getExternalStorageDirectory())));
            is.close();
            os.close();
        } catch (IOException ex) {
            Log.w("ExternalStorage", "Error writing " + file, ex);
        }
        return file.getAbsolutePath();

    }

This is the code I am using to save the image to the device gallery. However, after the image is saved, if i check the gallery imeediately, the image is not there. It comes when i reload the application, or the gallery after sometime. Any suggestion to this problem will be helpful.

  • 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-28T11:14:44+00:00Added an answer on May 28, 2026 at 11:14 am

    Try this:

    After adding your image in gallery you need to broadcast

    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse(“file://”+
     Environment.getExternalStorageDirectory())));
    

    Hopefully it will work for you. 🙂

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

Sidebar

Related Questions

I am trying to echo the action for my form if a post equals
So a form is submitted on my site, with form action equal to itself.
My action listener on a JComboBox invokes a thread. I would like the component
this action is generated in symfony 1.2 when you create a module: public function
when they say the action controller in the struts framework is multi threaded, does
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
My view-state to action-state transition does not appear to be happening. In the following
The Custom Action is configured as follows: Custom Action Name : MyCustomAction VBScript Filename
This is my action class public Iterator<CgConsultant> getSearchresult() { List<CgConsultant> list =userSearch.getConsultantMatches(searchstring); System.out.println(The size
I have a controller action that is being executed by a link that was

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.