Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-1191

Load/create a database in SD card

    XMLWordPrintableJSON

    Details

      Description

      I would like to be able to access or create an SQLite database on SD card in android/WP7 or in the persistent storage in iOS. Currently I am working in Android, so I will limit the comments to Android for now.

      Looking at the android code for openDatabase call in Storage.java, I see that if the path of the DB is null, it is set to app-path. But there is no way to set the path of the DB or pass it in the call. It seems like an easy fix: we need a call to set the path to a string, or accept a FileEntry object as the database in the same openDatabase call.

      Here is the relevant part of the code:
      (Accessed from https://github.com/apache/incubator-cordova-android
      as file: apache-incubator-cordova-android-2.0.0-16-g81ab0a4.zip)

      <<
      public void openDatabase(String db, String version, String display_name,
      long size) {

      // If database is open, then close it
      if (this.myDb != null)

      { this.myDb.close(); }

      // If no database path, generate from application package
      if (this.path == null)

      { this.path = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); }

      this.dbName = this.path + File.pathSeparator + db + ".db";
      this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
      }

      >>

      Please let me know if I am missing something. I am new to this stuff.
      Thanks and regards.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              samikrc Samik R
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified