We have developed an APK Application running on tablets. In this application we have created various csv files and by reading these csv files, the apk creates database(sqllite) files when running for the first time. This database file is used in the application in various dropdowns(masters in other keywords). I am facing a very serious issue in this. We have a csv file of around 12000 rows in it and because of this the apk takes around 1 hour for the first time. By first time, I meant when I install the apk on tablet and run it for the first time. This is becoming a very serious issue in my application and I need to resolve this. Can anyone give any idea how to overcome this.
You should try preprocess the SQL database using an Android emulator/device running a special version of your app, put the result DB in your release APK, and simply copy the DB over to the appropriate place during application's first run. The process of retrieving the DB from Android emulator/device can be found here.
Related
Technologies used for the app: Ionic, Capacitor, Angular and SQLite
The requirement is to use a prepopulated SQLite database in the app. The methods that I found over the internet across various blogs and forums mentioned running a SQL script to initialize the DB as a pre-population step, but this brings about an unwanted overhead time to start querying the DB. As in the user needs to wait for a minute or so for the SQL Script to run completely every time, even if the app exists.
This issue became a roadblock because when the need became to port a large-sized database, it was no longer feasible to write SQL scripts as the overhead time increased drastically. Also, a bigger problem is, in Android studio, Java started throwing Heap Memory exceeded error.
A solution that I tried was to port the database directly as an asset of the app so that it can be shipped along with the app. But, while placing the database file in src/assets/, every build of the app generates www/ to create a web app that can be wrapped in a native view. The builder and compiler delete all the contents of the previous build in the www/ folder, we must understand that the capacitor looks for the database file at www/ and not in www/assets/, but we can't place the database file at www/ as it gets deleted on every build.
Link to existing issue on using the sqlite extension
maybe my experience can help you
RULES FOR DEVELOPMENT
1
database1 of bundle ( Android APK) from /assets must be static and not for update. because they can be changed when the application will be reinstalled on you version
2
you must to create new database2 - local , on the device , programmatically - to store a user's data. you can affill this database2 with data from database1
3
when you will install new version of application: database1 one may be changed, but the database2 becomes constant
the same situation is in browser: programmatically created database not disappear from session to session.
I check - it works in my application...
I had a problem with my pc and I had to format the c drive without being able to access it, good things is that i only lost my app files, bad news is that I lost my app files hahah (not really laughing at all, more like a crying laugh). I used to test my app in my phone so i have it installed there, i have half of the progress I've made backed up (too bad i didn't change the app's folder, I am gonna do it from now on) but i would reaply like to recover it, so... Is there any way that can be done? If not well... learned the lesson the hard way I guess
You may be able to retrieve the java classes and resources from the apk. First, you can try pulling the apk from your Android device:
How do I get an apk file from an Android device?
Second, try retrieving java files from the apk:
how to extract code of apk file
It is called reverse engineering.
Here's a tool that might help you: https://ibotpeaches.github.io/Apktool/
Hope you will recover your code ;)
I am using sqlite to save some string values in the database, my app works perfectly in the emulator. But when I tried it on the Samsung Galaxy Tab, the log cat says that there are not such tables... before mounting the apk files to the device I have tried opening it in the archive mode and found the database and the tables secure in my "assets" folder.
Can any one tell me whats going wrong with me ?
thanks in advance...
Happy coding
Databases don't belong in the assets-folder! You should use a SQLiteOpenHelper-class to create and update your Database when it's needed.
Tutorial (or simply Google for it).
I have experience with the same thing you are experiencing now. This is a classic in device manufacturer fragmentation. It has happened to me before when trying to run an application on a Samsung Nexus S phone that had a method to copy a already existing database to the application from assets on install (i am guessing that's what you are doing at the moment). so long story short, after quite some testing the best and only solution i could find was to actually do the manual work and create the database with the help of the SQLiteHelper methods and table creating queries and recreate the same scheme. this method works 100% so far on every phone i have tried it so that's the safest thing you can do.
Hope this helps.
The db file should be available in "/data/data/YOUR_PACKAGE/databases/" folder in your device.
If this is the first time you are creating the db then you should copy the db file from your assets folder into the above location (the first time when you access the database).
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Android sqlite returned: error code = 14
I have a own created SQLite database that i include in assets folder in my Android app, its has works really good.
Before i start using first my realeased version from market and then uninstall the application with all data and run debug on my development version of the app, then i started get "sqlite returned: error code = 14" and what i can see when i logging is that its copying the file to the right folder and not getting any error.
But when its start reading from it its gets the error and then its can not find the tables in the file.
I have tried on my development phone to reinstall the whole phone and then all works again, i startaed install the Market released version then uninstalled it and install the development version and its no problem then.
But on my phone i using for everything else its still a problem and i dont whant to reinstall the whole phone for this.
I have tried uninstall the application with adb and still the same problem.
Someone out there that has any idea how to fix this?
Looks like not a problem for normal users but when i develop and using the different versions its some problem, and i has not changed the database between the two versions...
This happens when something bad has gone into the DB. By bad, I mean something SQLite is not able to read when get is used. That's why uninstalling the app and reinstalling it in the emulator typically works. The solution would be to look into what you are storing and figuring out where things are not OK.
(suggestion from user1526732): Use 'SQLite Database Browser' to examine your DB thoroughly!
Today this issue cost me 3 hours. What I tried:
Rewriting the copy database code.
Deleting the app from the emulator / device
Wiping emulator(s)
Cleaning eclipse
Changing file permissions
Validate that the SQLite database file is working
I solved the problem by copying the code from a shared Dropbox account to another location and refactoring the code in the Android Manifest and java files with another package name.
The application runs beautifully now.
I'm creating an app with 3 different languages. Every language contains a separate audio file (8 mb each).
Is it possible to split/export the project to 3 different .apk files prior to release on Market? I really do not want to put everything in one .apk due to the 24+ mb file size.
I can see a few options...
Manually build each one, release them as separate products in the Market in each language, e.g. "MyApp English", "MyApp Francais" etc. You could limit which countries see each one, to reduce confusion.
Same as above, but use Ant to automate the Android build process, so you can have one project for the app, but easily build a version in any language. Ant is quite involved, but I'd that in about a day you could learn enough to get an Ant build script running for your project. Android has built-in command line tools to help, so it'll create an initial Ant script for you (look at the "android" command line tool).
Create a single app, and when it starts, ask the user to confirm the language they want, and then start the download. Ideally you'd download a little bit initially to allow the app to work, and download the rest in the background so they don't have to wait. 8MB is quite a lot of data, so beware people will data expensive data plans so I think it is polite to always ask their permission for the download.
If it were me I'd probably lean towards the last option as it's simpler to build one app, and with sucha big download, the user needs to be in control of the process. Bear in mind many people wouldn't download an 8MB app if they knew beforehand it is that big.