Android Question Saving output to SQL Lite table

Discussion in 'Android Questions' started by GeoffT660, Jan 30, 2015.

  1. GeoffT660

    GeoffT660 Active Member Licensed User

    I'm now able to download or stream with httputils2 and read csv files or stream xml through the xml parser but what is the fastest and most efficient way of reading 1000's of records with 30 or 40 fields from a csv file or the xml parser into a SQL Lite table. The Sql Lite table will have the exact same structure as the downloaded csv file or streamed xml. I will need to do this on many different tables. Is it better to receive the info as a .csv file and read and parse the file, delimited stream or xml stream and parse with the parser. Thanks.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    CSV will be faster than XML. The important point is to create a single transaction for all the insert statements.
     
    GeoffT660 likes this.
  3. GeoffT660

    GeoffT660 Active Member Licensed User

    Thanks, I'll work with that. Is the fastest way to create the csv file on the server and download it to the device and read it from the file or to read it as a string directly to the table or some other way. I can receive the input either way but have only figured out the former to read from a file. Any ideas on that? Is it also possible to create the SQL Lite table on the server and replace it on the device? Do you have an example of a single transaction created from a csv file or inputstream that would insert all the records en masse?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    If you can create the SQLite database on the server then it is the simplest method. Just download the database file, close the existing SQL connection and replace the file.

    There are many examples in the forum of using transactions.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice