How to update an existing SQLite .db file?

Hi all,
I am developing a small todo application in AIR. I make use of a .db SQLite file to store data and stuff.
Now when my application is updated, the .db file will be overwritten. Is there a way to avoid this when it already exists?

Don't worry about it. We all started new at some point. Here's what I do with my AIR apps.
1) Package a prestructured db file with the application. The DB should include any data required for the app to run on it's first time. Generally this would include all of your tables, just empty.
2) In your startup functionality, use the function I provided previously. That function will run EVERY time the application loads, not just the first time. Let's flesh out the method with some additional functionality though;
var dbFile = air.File.applicationDirectory.resolvePath('yoursqlite.db');
function checkForDB () {
     if (!dbFile.exists) {
          var tmpDB = air.File.applicationDirectory.resolvePath('yoursqlite.db');
          tmpDB.copyTo(dbFile, true);
     } else {
          // if the db DOES exist, then let's query for the history
          // and fire it back up the event chain
          this.getHistory();
The extra lines check for the empty db you've included in your app, and COPY it to the AppStorageDirectory. So essentially if the db exists in the AppStorageDirectory then you''ll know that the app has been run at least once and you can assume that certain records exist.
If you'd like to see a JS AIR application, check out my Shrinkadoo project. Download and install it, then browse to the Program Files, or Applications, directory on your computer and check out the source. Feel free to poke around and gather whatever knowledge you're looking for.
http://www.andymatthews.net/code/Shrinkadoo/

Similar Messages

  • How to update an existing item in a sharepoint list using the WSS adapter for Biztalk

    Is there a way that a record in SP list be updated using WSS adapter in biztalk ?
    BizTalk 2013 and SP 2013 ..
    Regards
    Ritu Raj
    When you see answers and helpful posts,
    please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • How to update an existing app

    how to update an existing app by using a different apple id than the one used for the original download?

    Apps can only be updated using the Apple ID used to purchase them.

  • How to update an existing supplier using Supplier Open Interface Import?

    Hi
    I need to updated an existing supplier.
    Is it possible to update using supplier open interface import and how?
    Thanks in advance.
    Thanks,
    Mallesh

    Hi Atul,
    I am using CCM 2.0 and SRM 5.0 (EBP5.5).
    We are not using XI, so i guess we cant use the program "/ccm/file_upload".
    we have migrated the product master data from R/3.
    We have developed a report which takes product category as input and gives out flat file in csv format containg all the items in that prod category.
    Then we upload the file in CCM by logging thro the brpwser.
    Similarly, i can develop another program which will give me a CSV file foll all those items changed in R/3 in a day.
    Then we can upload that file in CCM.
    But i have doubt if it will update the existing items in catalog.
    Hope I could make myself clear.
    Thanks
    Abhishek

  • How to update the value in xml file using transformer after setNodeValue

    Hi,
    This is my code
    I want to set update the values in xml file using transformer..
    Any one can help me
    This is my Xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <place>
    <name>chennai</name>
    </place>
    Jsp Page
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page import="javax.xml.parsers.DocumentBuilderFactory,
    javax.xml.parsers.DocumentBuilder,org.w3c.dom.*,org.w3c.dom.Element"
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <% String str="";
    String str1="";
    try
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse("http://localhost:8084/XmlApplication1/sss.xml");
    out.println("Before change");
    NodeList n11 = doc.getElementsByTagName("name");
    Node n22= n11.item(0).getFirstChild();
    str1 = n22.getNodeValue();
    out.println(str1);
    out.println("After change");
    String name = "Banglore";
    NodeList nlst = doc.getElementsByTagName("name");
    Node node= nlst.item(0).getFirstChild();
    node.setNodeValue(name);
    NodeList n1 = doc.getElementsByTagName("name");
    Node n2= n1.item(0).getFirstChild();
    str = n2.getNodeValue();
    out.println(str);
    catch(Exception e)
    out.println(e) ;
    %>
    <h1><%=str%></h1>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    </body>
    </html>

    hi check this exit...
    IWO10012

  • AppBuilder:how to update data in a json file

    Hello
    I have built an android hybrid app with AppBuilder whitch retrieves data from a json file. How can i refresh the json file with new data?
    Is there any way to update the apk file in a device after new data entry in json?
    Any information is appreciated.
    Thank you in advance
    Angeliki

    Hi,
    For some time I have also been trying to do the same thing with no success. So far I have tried a few approaches like $.post functions $.ajax post functions and HTML5 fileWriter functions. I am not well aware of the web development techniques but as fas as I understand the post or update of the json file should be done on the serverside mainly because of security issues. I am not sure how appbuilder works entirely and if there is any way to do this.
    Have you managed to find a solution ?
    (P.S. my goal is to update my chart data which is of course json file. So the idea here is to get some values from the user input and update the json file values then refresh the chart and display it with the new values).
    Best Regards,
    A.Dyankov.

  • How to update data in a xml file.

    I am able to retrieve data from a xml file but not able to update data. Also how can i add or delete node from a xml file.

    Hi,
    For some time I have also been trying to do the same thing with no success. So far I have tried a few approaches like $.post functions $.ajax post functions and HTML5 fileWriter functions. I am not well aware of the web development techniques but as fas as I understand the post or update of the json file should be done on the serverside mainly because of security issues. I am not sure how appbuilder works entirely and if there is any way to do this.
    Have you managed to find a solution ?
    (P.S. my goal is to update my chart data which is of course json file. So the idea here is to get some values from the user input and update the json file values then refresh the chart and display it with the new values).
    Best Regards,
    A.Dyankov.

  • How to update last line in a file.

    Hi
    I need to append some text which should be at 2nd last line of a text file. I am getting the last line using RandomAccessFile and by ,
            fileHandler.seek(fileHandler.length()-1-lastLine.length()-1);
            fileHandler.writeUTF("last_line\r"+lastLine.replaceFirst("0x00", "0x80"));the above code i am trying to append the text with the updated last line. But instead of appending, the above code just replaces the last line.
    How to solve this problem ?
    BR
    Umer

    gimbal2 wrote:
    Muhammad Umer wrote:
    Hi
    I need to append some text which should be at 2nd last line of a text file. I am getting the last line using RandomAccessFile and by ,
    fileHandler.seek(fileHandler.length()-1-lastLine.length()-1);
    fileHandler.writeUTF("last_line\r"+lastLine.replaceFirst("0x00", "0x80"));the above code i am trying to append the text with the updated last line. But instead of appending, the above code just replaces the last line.
    How to solve this problem ?
    BR
    UmerRemember that a file, even a text file, is nothing more than a piece of administration: the administration of a collection of bytes to be exact. There are no lines, only bytes. Those bytes may represent something like a line, but that is basically only interesting during the presentation of data, the data itself has nothing to do with lines at all.
    So what you are doing is seeking to a specific location on the harddrive and you are writing some bytes. Whatever was there is overwritten by the new data. You assumed that what would happen is what you see happen in a text editor, that data is inserted at the spot of the cursor, but I hope you realize that you cannot make those assumptions. Also, what you see happening is not what the text editor application is actually doing; the difference between presentation and business logic.Thank you for such a nice explanation. I have solved the problem
    And for PrintWriter i will try it for understanding. Thank you.

  • How to update/write to a XML file using JSP?

    If a user enters information in a form, is there any way to write this information into an existing XML document using JSP? Basically, I want my users to be able to add new information into an XML file but I have no idea how to do it.
    Help appreciated.

    Java webservices tutorial should help
    http://java.sun.com/xml/index.jsp

  • How to update the record in a File (without closing Writer)?

    Well i've got one issue:
    I want my program to record in a file updating any time i.e the records are added in append.
    But i want the record must be done in a file even if the Writer is not closed because I'd like to see the all logs of user and the main thing is sometimes there could be issue of software crash, powercut off or any So for that reason i 've made code like this but it doesn't update but it only override:
    public boolean write(String s){
            boolean isFinished = false;
            try{
                FileOutputStream out = new FileOutputStream("C:\\new.txt"); 
                int i = 0;              
                while(i != s.length()){
                    out.write(s.charAt(i));
                    i++;
                //here i've not closed file output stream
                isFinished = true;
            catch(IOException i){
                i.printStackTrace();
                isFinished = false;
            return isFinished;
        }

    Well, Thanks for the help but,. i didn't understand
    try not opening the file every time. As I only know that I need to open a file if i would like to update the records..
    The update is not happening :
    Firstly it shows like this (new.txt):
    STOPSecondly it must show like this (new.txt) BUT NOT HAPPENING AS I EXPECTED:
    STOPSTOPBut it's not hapenning

  • How can I add existing issue/folio files to ipad?

    Hey,
    Before the new process originated I created several .issue files and sideloaded them via iTunes. I no longer have each individual article file, only the .issue files.
    How am I able to get these from my MacBook to my iPad? Every explanation I've found involves creating a new folio file and obviously I'm unable to do this without the individual article files.
    I'm new to digital publishing so sorry if there's a very simple answer! I did try uploaded to my Adobe account but the file didn't show for download on my iPad.
    Laura

    To save arbitrary document types in iCloud on MacOS X 10.9.5 have a look at Winston Churchill's User Tip: 
    See this link:  Using iCloud to sync multiple document types.
    This will work between Macs, but not for mobile devices.

  • So is this Possible to update already existed Receiver Flat/XML File ?

    HI ,
    On Receiver File (FTP) Side ,So is this Possible to update already existed FLAT/XML File with some values using Receiver File Adapter??
    Like I have 3 Columns in a Flat File/XML File :-
    Name,  Deptid,  Expenses.
    NameA, 8000,   -
    Currently Blank -
    NameB, 1000,  -
    Currently Blank----
    Now I want to Update Existing Flat file from Receiver File Adapter
    After Execution of scenario, Fileon FTP server would be Updated like this
    Name,  Deptid,  Expenses.
    NameA, 8000,   18000
    NameB, 1000,   25000
    So is this Possible to update already existed FLAT/XML File with some values using Receiver File Adapter?

    I am dealing with similar type of scenario..
    If that way it is not possible , So please guide me what other workarounds can be done ..........???
    Does FTP Sender Support Synch Call... ???
    regards

  • Delete and update contents in a CSV File

    Hi All,
    I am new to java . I am able to read the records from CSV file using BufferedReader and I am getting output like this
    "100,a100,1b100" -->1st record
    "200,b200,dc300" -->2nd record
    "400,f344,ce888" -->3rd record.
    Now I need some help in below requirements.
    1.How to delete a specfic record?
    2.If record already exists how to update the existing record with new values?
    Please share your ideas or give me some code snippet..
    Thanks in Advance

    Or if each record is the same length and you are not inserting -
    just modifying values in existing ones - you can use a
    RandomAccess file.
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/RandomAccessFile.html

  • How to update entries of already uploaded master data?

    Hi Experts,
    Master data for one of the infoprovider 0PROMOTION has uploaded with blank value for one of it's attribute zcatgrp and zcatgrp master data is being maintained in BI. Recently one more Zcatgrp has been uploaded but business wants existing records with this new catgrp .
    Please suggest how to update the existing master data entries?
    Regards,
    BW USER

    RELOAD the masterdata with zcatgrp for the promotions.
    when you reload the masterdata with the zcatgrp associated to the promotion (key), the existing records(with blank values) would be overwritten with new records with the associated zcatgrp value.

  • How do i update an existing XML File?

    Hello, I have the following xml file gps.xml:<?xml version="1.0"?>
    <!DOCTYPE gps SYSTEM "gps.dtd">
    <gps>
       <latitude>43.00000</latitude>
       <longitude>-83.00000</longitude>
    </gps> I already have methods written to get the values. But how can I change these values and update the file to reflect these changes?
    thanks for your help!

    Hi, I already have this following code. I would just like to add a method to it to update the existing XML file with different lat/lon coordinates. Could you please help me out with it? thanks
    import java.io.*;
    import java.io.PrintWriter;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class Gps implements java.io.Serializable {
        private double latitude_;
        private double longitude_;
        public Gps(Document doc) {
            setup(doc.getDocumentElement());
        public Gps(String uri) throws IOException, SAXException, ParserConfigurationException {
            setup(uri);
        public void setup(Document doc) {
            setup(doc.getDocumentElement());
        public void makeElement(Node parent) {
            Document doc;
            if (parent instanceof Document) {
                doc = (Document)parent;
            } else {
                doc = parent.getOwnerDocument();
            Element element = doc.createElement("gps");
            int size;
            URelaxer.setElementPropertyByDouble(element, "latitude", this.latitude_);
            URelaxer.setElementPropertyByDouble(element, "longitude", this.longitude_);
            parent.appendChild(element);
         public Document makeDocument() throws ParserConfigurationException {
            Document doc = UJAXP.makeDocument();
            makeElement(doc);
            return (doc);
        public final double getLatitude() {
            return (latitude_);
        public final void setLatitude(double latitude) {
            this.latitude_ = latitude;
        public final double getLongitude() {
            return (longitude_);
        public final void setLongitude(double longitude) {
            this.longitude_ = longitude;
       public final void updateXmlFile(double latitude, double longitude) {
         // something???
        public final void updateXmlFile(double latitude, double longitude) {
            this.latitude_ = latitude;
            this.longitude_ = longitude;
        public String makeTextDocument() {
            StringBuffer buffer = new StringBuffer();
            makeTextElement(buffer);
            return (new String(buffer));
        public void makeTextElement(StringBuffer buffer) {
            int size;
            buffer.append("<gps");
            buffer.append(">");
            buffer.append("<latitude>");
            buffer.append(Double.toString(getLatitude()));
            buffer.append("</latitude>");
            buffer.append("<longitude>");
            buffer.append(Double.toString(getLongitude()));
            buffer.append("</longitude>");
            buffer.append("</gps>");
        public String toString() {
            try {
                return (makeTextDocument());
            } catch (Exception e) {
                return (super.toString());
    }

Maybe you are looking for

  • How to run Standalone Server as a Service in Linux

    Hi, I need run an Standalone server in Java as a Service in Linux RedHat? How to do this? some example or link to helpful sample code? How I can execute as a service in Linux RedHat 9 the following server Application? import java.io.*; import java.ni

  • Access Denied with EJB Deployment to 8i with JDeveloper

    Hi, I'm having a problem deploying an EJB to Oracle 8i with JDeveloper 2.0. I am receiving an insufficient privileges error in the deployment process when it reaches the stage Generating EJBHome and EJBObject on the server. I am logging in using the

  • What does this command do?

    [root@fackamato-laptop ~]# dd if=/dev/zero of=/dev/null bs=1M count=100000 100000+0 records in 100000+0 records out 104857600000 bytes (105 GB) copied, 10.5889 s, 9.9 GB/s [root@fackamato-laptop ~]# dd if=/dev/zero of=/dev/null bs=1M count=100000 100

  • Which font management software to use?

    Hi friends Can some one suggest a font manager application for TTF & postscript font. Is Corels 'Font navigator' good? I used to use Adode ATM deluxe but they hav discontinued it.. which one is the latest? Snehal

  • An unexpected severe error has ocurred in Jdeveloper

    Hi, I have installed Jdeveloper with soa-jdev-extension on my windows 7 64 bit machine. I created a SOA project with BPEL and human task in it. I wanted to import an xsd into my project so i right clicked on the import folder in the structure pane an