Comments (5)
@eugenezhornyak
First thanks for using the plugin, i spent my afternoon to try understanding what is wrong. In fact the main reason is that the way you want to work with the plugin is questionable. In fact, the sqliteService
instance use in DatabaseInitializationService
and the one ProductsRepositoryService
is not the same meaning that the
res = mDb.querySQL(statement, new ArrayList<String>());
``` in the CapacitorSQLite.java file the mDb is null as the open method has not been called for that instance.
The way you make your `readAll()` method in `ProductsRepositoryService` is wrong. It should be
async readAll(): Promise<Product[]> {
/*
return this.executeIfDbExist(this.selectAllCommand).then(result => {
console.log('Read products result:' + JSON.stringify(result));
return result;
});
*/
return await this.sqliteService.query(this.selectAllCommand);
}
YOU DO NOT REALLY NEED TO EXECUTE executeIfDbExist
as when you run the database.initialization.service.initializeDatabase()
if it return false you do not execute in Home page the refreshData()
if you still do it, it will slow down the app for nothing
I didn't find the way to make the SQLiteService a singleton through the app.
From Angular doc
Providing a singleton service
There are two ways to make a service a singleton in Angular:
- Set the providedIn property of the @Injectable() to "root".
- Include the service in the AppModule or in a module that is only imported by the AppModule
I have tried both but i did not find the way to make it working.
Look at `https://github.com/jepiqueau/angular-sqlite-app-starter` this one works, and build your application along that.
If you find the way to make the SQLiteService a singleton, i will be interested in
from sqlite.
@eugenezhornyak i have found the solution. I have to update first the android plugin to implement a listener for granted permissions and after this i will share the app.
from sqlite.
@eugenezhornyak have a look at https://github.com/jepiqueau/test-sqlite-issue51
You cannot instantiate DatabaseInitializationService
in the ngAfterViewInit
lifecycle event on the app.component
as the router bring you straight forward in the Home
page. Hope this will help.
from sqlite.
@jepiqueau Thank you for attention paid! Your solution is very helpful. My problem solved
from sqlite.
@eugenezhornyak Happy that everything works fine. i close the issue
from sqlite.
Related Issues (20)
- ionic7-angular-sqlite-app tutorial ionic.config.json type angular-standalone doesn't exist HOT 1
- ionic7-angular-sqlite-app tutorial fails on v5.7.1 HOT 6
- GetFromHTTPRequest not working HOT 3
- Multi Row Statement does not escape characters HOT 4
- Multiple Row Statement Values case insensitive HOT 3
- Multirow statements inserts wrong semicolon HOT 2
- foreign key ON DELETE CASCADE HOT 1
- Create CapacitorJS v6 package compatibility HOT 32
- ExecuteTransaction with values throws exception for statements performing no actual changes HOT 5
- Memory leak using .saveToStore() HOT 18
- Migration not working on iOS HOT 3
- executeSet not inserting rows HOT 8
- Multi Value Statement error with spaces inbetween ? HOT 1
- Multi row statement should fail if no values are replaced HOT 4
- Can I use this plugin inside the background runner capacitor plugin? HOT 2
- Update Capacitor dependencies to version >6 HOT 2
- Connect to SQLite database on external storage directory using capacitor sqlite plugin HOT 2
- TypeError: Cannot read properties of undefined (reading 'lastId') HOT 4
- Feature: Capacitor 6 support HOT 1
- exportToJson generate unusable export for table created with separate UNIQUE syntax. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite.