-
-
Notifications
You must be signed in to change notification settings - Fork 53
copy database just copies from assets #37
Comments
@kazemihabib I also ran into this problem (on android) of trying to download a database from a remote server and then call copyDatabase on the downloaded file but even though the file has been downloaded to the apps directory copyDatabase doesn't find it. I posted my code snippit in this github issue. couple questions: are the assets folder and app folder 2 different locations? How did you get around this by copying manually? If I instead embed the sqlite file in the apps folder before building the app then the copyDatabase call works. |
@NathanaelA is the path that copyDatabase() tries to copy from the same as fs.knownFolders.currentApp().path? On my system that resolves to /data/data/org.nativescript.myappname/files/app |
@jeffswitzer - Yes. The copy from path is the root of the app which is that path. The copyDatabase is really just designed to be a very simple helper for those who include the database as part of the built in app; so that it can be installed in the place that it needs to be. It is not a general purpose routine. :-) |
@jeffswitzer I didn't implement it yet , but I know it's possible for example:http://stackoverflow.com/questions/22531789/copy-database-from-sdcard-to-data-data-packagename-databases-folder |
I am willing to accept a pull request that implements this functionality; or you can contract with me or another contractor to add this feature. |
Hi everyone, I tried @kazemihabib solution and it works. I have a custom db service (db.service.ts) (did not overloaded nativescript-sqlite library). I use Angular2 I have to use Android DownloadManager to download DB file. Here is my code: (maybe it will help to someone)
|
I'd also like to have it copied from the SD card, or even accessed from there, without needing to copy it to the folder /data/data/org.nativescript.myappname/files/app |
@kazemihabib @shastik thanks much... finally just got back to this and the above code helped me to get it working. |
Hi, I need help with copyDatabaseAndroid(name, currentDBPath, oldName). (angular)Me code is the next: component.ts var filePath = fs.path.join(fs.knownFolders.currentApp().path, "init2.db"); http.getFile("http://meemba-webs.com.ar/beeorder/init2.db", filePath).then(downloadedFile => { service.ts public setDB(name, path) : void{
private copyDatabaseAndroid(name, currentDBPath, oldName) {
|
I read this thread first but could not easily extract the key source code. I found another post showing very concise source code (also notice the comment later about checking for the existence of the folder). Maybe, this will help other people facing this issue. https://discourse.nativescript.org/t/downloading-and-using-an-sqlite-db-file-where-does-it-go/6567/4 |
hi,
the
copyDatabase
just copies the database from assets (Android I didn't check ios) but there are situations that we need to copy it from sdcard to database folder (like downloading it from server).I know we can copy do it manually, but if
copyDatabase
supports that it would be really good.The text was updated successfully, but these errors were encountered: