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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:39:43+00:00 2026-06-12T14:39:43+00:00

I am facing a slight issue while editing a file. I am saving a

  • 0

I am facing a slight issue while editing a file.

I am saving a file (image) with a certain name on ios using the code below.
But the problem is that when i replace the image stored in a file (eg temp.jpg) the app still picks up the previous image when i open the file. However the new image can be seen in the explorer.
If i restart the app the new image appears while opening the image.

var folder = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'DocImages');

 // DocImages is a folder for files
 // ImageVar contains the blob for the new image from camera or gallery
 // docImgModel is the model class containing the name and image path of the image

 if(imageVar !== null && imageVar !== undefined){
         if (docImgModel.imagePath !== null && docImgModel.imagePath !== undefined){
              tempFile = Ti.Filesystem.getFile(docImgModel.imagePath);
              if (tempFile.exists()) {
                      tempFile.deleteFile(); // deleting already existing file
              }}


              // in case of changing the image stored in a file(the case in which i have a  
              // problem) the imgFile(below) is same as docImgModel.imagePath (above)

              imgFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory + 'DocImages/', filenameWithExtension); // creating a new file


              // writing image to file
              imgFile.write(imageVar);
              Ti.API.info('new image saved');

              }

}

I was wondering if titanium saves cache of the file already opened and is hence not able to show the new image.
If not, is there anything else i am doing wrong or something i could do to make it work.

I just want to show the new saved image. Is there any way to do it.

Thanks.

  • 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-12T14:39:44+00:00Added an answer on June 12, 2026 at 2:39 pm

    I haven’t worked with opening files from the device, but I ran into a similar issue when trying to update data on my screen. If you are saying when you open the app and it loads the correct image comes up, then the code that you use to load the image appears correct and working. I assume that is the code you posted above. Even that appears to be a code fragment of a more complete file.

    You didn’t post any UI code, which is probably where your real problem is coming from. You have an object, a view of some sort I’m guessing, that is already rendered using the old image before you load the new image. So debugging, you might see the new image’s data loaded in the code above, but the UI element hasn’t been assigned or updated correctly.

    As a test, I would suggest that you put some test code into your app that allows you to destroy your UI elements and recreate them, you will probably see the picture come up properly in that case.

    According to this post: http://developer.appcelerator.com/question/31181/simple-image-refresh

    Just assigning the image you loaded to the url of the image should update it. Your example code doesn’t show the image object that you are attempting to update and how that communication is made from the code that is loading the image.

    // this sets the background color of the master UIView (when there are no windows/tab groups on it)
    Titanium.UI.setBackgroundColor('#000');
    
    // create tab group
    var tabGroup = Titanium.UI.createTabGroup();
    
    var image1 = 'image1.png';
    var image2 = 'image2.png';
    
    //
    // create base UI tab and root window
    //
    var win1 = Titanium.UI.createWindow({  
        title:'Tab 1',
        backgroundColor:'#fff'
    });
    var tab1 = Titanium.UI.createTab({  
        icon:'KS_nav_views.png',
        title:'Tab 1',
        window:win1
    });
    
    var img = Titanium.UI.createImageView({
        width:100,
        height:100,
        top:50,
        left:110,
        url:image1
    });
    
    win1.add(img);
    
    var btn = Titanium.UI.createButton({
        title:'load',
        width:100,
        height:35,
        top:50,
        left:0
    });
    
    function switchImage(){
        if(img.url == image1){
            img.url = image2;
        } else {
            img.url = image1;
        }
    }
    
    btn.addEventListener('click',function(){
        switchImage();
    });
    
    setInterval(switchImage,3000);
    
    win1.add(btn);
    
    //
    //  add tabs
    //
    tabGroup.addTab(tab1);  
    
    
    // open tab group
    tabGroup.open();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

issue facing while loading the messages in to mq channel, recieving an error like
Am facing a problem, while creating components through TOM API using .NET/COM Interop. Actual
I am new to Android development and am facing a slight issue. My first
I facing issue in iOS 6 iPad On button click -> open popover with
we are facing a strange issue. we have a (custom)file upload control in our
im facing a problem regarding my .htaccess file here is the code within the
I am facing an issue while loading a UIWebView .I have a webview(1st) where
I am facing a strange behavior with In-App-Purchase in iOS while testing with sandbox.
Im facing an issue which I believe to be VAO-dependant, but Im not sure..
I'm facing a slight issue at the moment. I am currently doing some video

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.