Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Mobile Development
  3. Android
  4. Saving xml date in sql lite

Saving xml date in sql lite

Scheduled Pinned Locked Moved Android
databasexml
6 Posts 4 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11705193
    wrote on last edited by
    #1

    Dear sir. I am getting data in xml format. I want to save that in sql lite. Note if is whole xml as not in string which i am getting.

    S L D 3 Replies Last reply
    0
    • U User 11705193

      Dear sir. I am getting data in xml format. I want to save that in sql lite. Note if is whole xml as not in string which i am getting.

      S Offline
      S Offline
      Sascha Lefevre
      wrote on last edited by
      #2

      Member 11739620 wrote:

      Note if is whole xml as not in string which i am getting.

      Not sure what you want to say here. But as XML is always plain text by definition you could just store it in a text-type column. If your XML is not just plain text then it's not valid XML.

      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

      U 1 Reply Last reply
      0
      • S Sascha Lefevre

        Member 11739620 wrote:

        Note if is whole xml as not in string which i am getting.

        Not sure what you want to say here. But as XML is always plain text by definition you could just store it in a text-type column. If your XML is not just plain text then it's not valid XML.

        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

        U Offline
        U Offline
        User 11705193
        wrote on last edited by
        #3

        I am getting xml from server. how to store that all xml tag in string.

        S 1 Reply Last reply
        0
        • U User 11705193

          I am getting xml from server. how to store that all xml tag in string.

          S Offline
          S Offline
          Sascha Lefevre
          wrote on last edited by
          #4

          XML is a string.

          If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

          1 Reply Last reply
          0
          • U User 11705193

            Dear sir. I am getting data in xml format. I want to save that in sql lite. Note if is whole xml as not in string which i am getting.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Your question is not very clear, but if you are wanting to extract the content of the XML, you should take a look at http://developer.android.com/training/basics/network-ops/xml.html[^], for how to parse it.

            1 Reply Last reply
            0
            • U User 11705193

              Dear sir. I am getting data in xml format. I want to save that in sql lite. Note if is whole xml as not in string which i am getting.

              D Offline
              D Offline
              Dadecki
              wrote on last edited by
              #6

              Hello, I will try to show you the possibility to save the data with SQLite in Android application: Firstly add import:

              import android.database.sqlite.SQLiteDatabase;

              1. Declare your database value in your Activity class:

              private SQLiteDatabase _yourDBname;

              1. Also declare name of the table in you database in Activity class:

              private String YourTableForXml = "XMLtable";

              1. In your Activity class in onCreate method initialize earlier declared database:

              @Override
              protected void onCreate(Bundle savedInstanceState)
              {

              _yourDBname=YourActivityName.this.openOrCreateDatabase("NameofYourDB", Context.MODE_PRIVATE, null);

              };

              1. Now you must prepare your table structure (in onCreate method too):

              _eSubSQLliteDB.execSQL("DROP TABLE IF EXISTS '" + YourTableForXml + "'");
              _eSubSQLliteDB.execSQL("CREATE TABLE IF NOT EXISTS " + YourTableForXml + " (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, xmlColumn VARCHAR);");

              1. Now you are ready to insert some xml to your table. Note that xml is just normal String value: String sampleXML = "

              <note>
              <to>Tove</to>
              <from>Jani</from>
              <heading>Reminder</heading>
              <body>Don't forget me this weekend!</body>
              </note>

              "

              ContentValues insertValues = new ContentValues();

              insertValues.put("XmlColumn", sampleXML);

              _yourDBname.insert(YourTableForXml, null, insertValues);

              Hope this will help you.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups