Coder Social home page Coder Social logo

Comments (3)

an-rahulpandey avatar an-rahulpandey commented on May 29, 2024

Hi,
If you read here - https://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper

SQLiteOpenHelper requires to open the db in readable or writable format first before performing an action first. I do not remember why exactly I try to open the database before copying it, rather than directly copying it to native location.

I will create one test copy of the plugin which just copy the db whenever I get time.

from cordova-plugin-dbcopy.

bryans99 avatar bryans99 commented on May 29, 2024

As near as I can tell, dbcopy is not aware of sqlite-storage. I am using sqlite-storage to control access to the databases (open, close, delete etc). dbcopy is just being used to copy from the location where the database is downloaded to, to the location where the databases are stored. The advantage of dbcopy is that it figures out the location of the databases. Prior to the copy, I close and delete the file using sqlite-storage.

I figured out what was happening by using the built in Android database classes (androidDatabaseImplementation: 2). When using this implementation three files are created in the database directory when the database is opened.

-rw------- 1 u0_a81 u0_a81 69632 2018-06-19 17:40 Code.db
-rw------- 1 u0_a81 u0_a81 32768 2018-06-19 17:40 Code.db-shm
-rw------- 1 u0_a81 u0_a81 412032 2018-06-19 17:40 Code.db-wal

After using copyDbFromStorage, I noticed the same three files being created. sqllite-storage is not aware of the database being opened so I cannot use it to close the database. When I open the database using sqllite-storage, the database appears to be empty (although on the file system, the size does not change). As soon as I close the database, the file is truncated.

I guess an alternate possibility is to close the database after the copy. If I get a chance I will try that today.

Thanks.

from cordova-plugin-dbcopy.

an-rahulpandey avatar an-rahulpandey commented on May 29, 2024

@bryans99 Yes, thats a good observation, closing the database after opening in the plugin might do the trick. Let me see if I can quickly do it.

from cordova-plugin-dbcopy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.