B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #1 I am trying to use the below code to get an externally created SQLite database (created with DB Browser) onto a phone. I've seen another thread concerning this but none of the tips have helped me. If File.Exists(File.DirInternal, "Inventory.db") = False Then File.Copy(File.DirAssets, "Inventory.db", File.DirInternal, "Inventory.db") End If The error I receive is: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) I've selected the database and added it to my Default Group. I also added to the project Manifest android:name="android.permission.WRITE_EXTERNAL_STORAGE". Is it failing on the Windows side or on the Android side? How else can I get the database to the device if this doesn't work? Thanks in advance!
I am trying to use the below code to get an externally created SQLite database (created with DB Browser) onto a phone. I've seen another thread concerning this but none of the tips have helped me. If File.Exists(File.DirInternal, "Inventory.db") = False Then File.Copy(File.DirAssets, "Inventory.db", File.DirInternal, "Inventory.db") End If The error I receive is: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) I've selected the database and added it to my Default Group. I also added to the project Manifest android:name="android.permission.WRITE_EXTERNAL_STORAGE". Is it failing on the Windows side or on the Android side? How else can I get the database to the device if this doesn't work? Thanks in advance!
M Mahares Expert Licensed User Longtime User Dec 8, 2021 #2 Bernard Harris said: The error I receive is: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) Click to expand... 1. Remove the permission statement from manifest. No need for permission. 2. The database needs to be added to the assets folder by clicking on the 'Add Files' button in the IDE files tab. Look for the file on your PC, then click it when you find it and then click 'open to put it properly in the assets folder. Upvote 0
Bernard Harris said: The error I receive is: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) Click to expand... 1. Remove the permission statement from manifest. No need for permission. 2. The database needs to be added to the assets folder by clicking on the 'Add Files' button in the IDE files tab. Look for the file on your PC, then click it when you find it and then click 'open to put it properly in the assets folder.
B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #3 I did do that, just forgot to mention it. And it copied the database file to the directory also. Upvote 0
M Mahares Expert Licensed User Longtime User Dec 8, 2021 #4 Bernard Harris said: I did do that, just forgot to mention it. And it copied the database file to the directory also. Click to expand... Code: Copy If File.Exists(File.DirInternal, "inventory.db") = False Then file.Copy(File.DirAssets, "inventory.db", File.DirInternal, "inventory.db") End If Try to change the code to lower case for inventory.db instead of Inventory.db.That might be it. If you want to export your project so members can check it out. The problem could be somewhere else. Upvote 0
Bernard Harris said: I did do that, just forgot to mention it. And it copied the database file to the directory also. Click to expand... Code: Copy If File.Exists(File.DirInternal, "inventory.db") = False Then file.Copy(File.DirAssets, "inventory.db", File.DirInternal, "inventory.db") End If Try to change the code to lower case for inventory.db instead of Inventory.db.That might be it. If you want to export your project so members can check it out. The problem could be somewhere else.
B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #5 Thanks for your quick response by the way! So I changed it to lower case and then put a break point on this code. This code is in the Starter Service_Create Sub and it's the first thing executed. It did not find the file existing on the phone so it then executed the Copy statement. Then it failed immediately with the error: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) One question I have on this is - why is it looking in this particular folder, that's not the folder in Windows? Is this the folder on the Windows side, the Android side, or the package itself that it built in Windows? Another note on this: I am able to successfully create the table myself and insert test rows within the same Sub but now I want to pull my actual data in and having this difficulty. Upvote 0
Thanks for your quick response by the way! So I changed it to lower case and then put a break point on this code. This code is in the Starter Service_Create Sub and it's the first thing executed. It did not find the file existing on the phone so it then executed the Copy statement. Then it failed immediately with the error: java.io.FileNotFoundException: /data/user/0/b4a.example/files/virtual_assets/inventory.db: open failed: ENOENT (No such file or directory) One question I have on this is - why is it looking in this particular folder, that's not the folder in Windows? Is this the folder on the Windows side, the Android side, or the package itself that it built in Windows? Another note on this: I am able to successfully create the table myself and insert test rows within the same Sub but now I want to pull my actual data in and having this difficulty.
M Mahares Expert Licensed User Longtime User Dec 8, 2021 #6 If you want to export your project so members can check it out, that is great. I don't think it is a big problem. Upvote 0
If you want to export your project so members can check it out, that is great. I don't think it is a big problem.
B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #7 Here is my project. I haven't built one for a couple years now so it might be rough but nothing too out of the ordinary. Attachments Foodstuff.zip Foodstuff.zip 19.4 KB · Views: 425 Upvote 0
Here is my project. I haven't built one for a couple years now so it might be rough but nothing too out of the ordinary.
M Mahares Expert Licensed User Longtime User Dec 8, 2021 #8 It worked for me. I did not do anything Here is a screen shot of the first page. Try to uninstall the app and install it all over Attachments Bernard.png 104.1 KB · Views: 570 Upvote 0
It worked for me. I did not do anything Here is a screen shot of the first page. Try to uninstall the app and install it all over
B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #9 Well that's about weird. It worked when I uninstalled from the phone and then rebuilt it. Thanks for the help! Upvote 0
Well that's about weird. It worked when I uninstalled from the phone and then rebuilt it. Thanks for the help!
M Mahares Expert Licensed User Longtime User Dec 8, 2021 #10 Bernard Harris said: It worked when I uninstalled from the phone and then rebuilt it. Click to expand... That's good. It is a very good project by the way, although I did not dive too much into it. Nothing to be ashemed of. You might want to start working with B4XPages project. as Erel always advises these days. You may want to change: Code: Copy p.SetLayoutAnimated(100, 0, 0, 100%x, 50dip) to this, you will get the attached look: Code: Copy p.SetLayoutAnimated(100, 0, 0, 100%x, 100dip) ' Attachments Bernard2.png 76.8 KB · Views: 516 Upvote 0
Bernard Harris said: It worked when I uninstalled from the phone and then rebuilt it. Click to expand... That's good. It is a very good project by the way, although I did not dive too much into it. Nothing to be ashemed of. You might want to start working with B4XPages project. as Erel always advises these days. You may want to change: Code: Copy p.SetLayoutAnimated(100, 0, 0, 100%x, 50dip) to this, you will get the attached look: Code: Copy p.SetLayoutAnimated(100, 0, 0, 100%x, 100dip) '
B Bernard Harris Member Licensed User Longtime User Dec 8, 2021 #11 Thank you! I have been programming now for 38 years and built only one Android program using B4A a couple years ago. It is a Load Delivery app for the company I work at. It's doing well even though it's outdated. I enjoy the Basic language the most because it's truly a RAD environment. Thanks again for the quick response and your help, I appreciate it greatly! Upvote 0
Thank you! I have been programming now for 38 years and built only one Android program using B4A a couple years ago. It is a Load Delivery app for the company I work at. It's doing well even though it's outdated. I enjoy the Basic language the most because it's truly a RAD environment. Thanks again for the quick response and your help, I appreciate it greatly!
klaus Expert Licensed User Longtime User Dec 9, 2021 #12 I suppose that the problem was the Package name B4A Example. When you develop a program or even when you download programs from the forum always change the Package name and the Application Label as described in the B4X Getting started booklet. Upvote 0
I suppose that the problem was the Package name B4A Example. When you develop a program or even when you download programs from the forum always change the Package name and the Application Label as described in the B4X Getting started booklet.
B Bernard Harris Member Licensed User Longtime User Dec 9, 2021 #13 Thank you Klaus! I will set these as recommended. Upvote 0