For my android application, I am using an AutoCompleteTextView. I want it so that the user types in a few letters of a city and there will be a popup showing the cities that match those letters. But, in order to do this, I need the list of all the city names. I have a .csv file and a .sql file containing all the data of the cities in the world. However, I do not know how to read such a large file effeciently. The file is approximetely 50 MB. Can someone please help me read or store this file so I can use it in my AutocompleteTextview? Thank you in advance!
You can't create android app greater than 50 mb, or you must use APK extension files.
With raw csv "cities" file with size of 50 mb or more, data base will be too big anyway. For you needs better solution will be access to online data base, store data online and read it from your app. I am sure, you can use some google API for it.
Related
I'm working on a dictionary app based on an SQLite database with well over 300,000 rows.
The problem is that the database file in its final form consists of full-text indexed tables and weighs well over 150Mb.
I've managed to bring the .db file size to a minimum by creating a contentless fts4 tables. The database cannot be any smaller. I also managed to put the pre-populated database in the app and it works fine.
The problem is that I can't just keep the final .db file in /assets and copy it to sdcard on first run because it's too big. I also don't want to download it on first run.
Bulk INSERTing the data, even with transactions and sqlite optimized and no indexes at start takes forever so it's also not an option.
The good thing is the raw data used to build the database, in CSV format and compressed, is 30Mb and sqlite's command line .import option is very fast (100,000 rows in ~1s) but... it can't be accessed from the app without root permissions.
I would love to bundle the app with compressed CSV files in /assets, decompress them, create the database on sdcard and then import the CSV but that seems to me to be impossible. Although there are many dictionary apps that appear to be doing exactly this. (The downloaded app is a dozen megabytes, builds database on first run, and takes hundreds of megabytes of space on the sdcard).
How do I accomplish this?
I've been working on this for past two weeks and simply ran out of ideas. I'm new to Android development so any help would be much appreciated.
Plan A: ship a compressed SQLite database file and decompress it after installation; you should be able to omit indices and rebuild them later.
Plan B: copy the relevant parts of the CSV importer into your application, ship a compressed CSV file and load it into an empty database like the command line tool would. Official documentation page.
Create entire content into csv file possibly multiple csv files and compress into zip. I have checked with 32 mb csv file after compression the file become 482KB.
For Example
data1.csv
data2.csv
data3.csv
data4.csv
data5.csv
compress the files into data.zip and put file into asset folder, when importing - extract file from the zip one by one and insert into sqlite db.
Recently i am developing application for android and blackberry.
What i need to do is to store a 32MB Sqlite file in project as initial database for application uses. In case of android it is simple and i can easily store this large file in assest folder but i m having hard time trying to make this work in blackberry why because as per RIM announcement App size should not be larger then 15 MB.
http://forums.crackberry.com/blackberry-os-apps-f35/rim-explains-app-memory-limit-637544/
Can anybody help me if is there any other trick strikes to make this happen.
To download a 32 MB file during Application startup is not a good idea. It'll take long time to navigate user into application.
Many thanks in advance.
Any help would be highly appreciated.
I've been thinking about this yesterday after work, and I think you could also try including the same data the DB contains, but in a compressed format, such as the first time the app is run, you create and populate the larger local sqlite DB from it, then delete the compressed data.
For instance, you could create a CSV dump of each table, and save it to a .csv file (i.e.: table.csv). Then you could then gzip each one to a file (i.e.: table.gz). You then compile every compressed file in a second resource module for your app (i.e: res_module.cod). When you install the app, this module is also installed and it copies its files to SDCard. Then the main module reads the files from the SDCard, ungzipping them and populating each table from them. After that, you can programmatically uninstall the assests module and delete the sdcard temporary files. The requirement for this to work is the compressed files should be smaller than 14 MB to fit in one cod file.
As for the DB schema, maybe a format for exporting it already exists, otherwise you could make your own format, or if the DB is unlikely to change, then hardcode it (bad practice).
I'm building a dictionary application and I have a problem right now. My application's is 16MB and when I install it on a phone, Database files copies to the data folder and in the manage apps section I see that my application size is 32MB (my app+data folder).
I don't cheat user, I want to say, my app is 16MB, but when user install it , it become 32MB. Why? this is a negative point and I want to solve it. I want my app uses only 16MB in users phone. just that
How I can fix this? I have to read and write in assets folder directly or there is other solution? this is a problem in low storage size phones. how I can fix this?
I am not sure how your database is structured in terms of whether it is a pre-loaded database wherein you just include you .db file with all the data OR is it something where in you push all your DB content with the app and then at the time of app installation you actually install all you data in the DB.
In case of the latter situation you double the size of your app because you already have data content (in files) which you want to use to populate your database (say 16 mb in this case). Then you use these files to actually create your DB file (which is 16mb again) and this doubles the size of the app.
So what you could do is pre-populate your DB content in a .db file and then just use this file directly as the Db file in your app (this will keep it to 16mb). Follow this tutorial :
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Hope this helps.
Not sure I fully understand your situation.
Do you have a roughly 16MB dictionary, that is packaged inside your app as string constants in your code or some resource file or something (to make it 16MB) and then, when your app installs or first launches, you also write this dictionary into your app's database?
If so, then now you have 2 copies of your dictionary around to make it 32MB.
To solve this, either keep only one copy in your app, or download the dictionary from somewhere to get it into your database rather than storing it as a constant in your app.
I'm trying to work on an app which uses GTFS. This may seems like a stupid question but I couldn't find any answer to it.
The GTFS for Israel, a rather small country with not so many buses infrastructure, is around 120 MB zipped file.
Right now the only possible way I could think of for getting it working is to download the file, but downloading 120 MB using the phone could take quite a long time. Sure you can do this only once and save it in a database on the phone, but it still requires downloading 120 MB.
Since it is zipped, I can't unzip it over the server and than just get the txt files..
So basically I'm asking, How can I get the information to the phone, without downloading the zipped file?
I've seen and used apps which uses that same GTFS file, and they load up really fast, even on the first load..
I hope you understand my issue, not sure how to explain it better.
Thanks!
P.s I would make an iPhone app too, and it's the same issue, hence the iPhone tag
One approach might be to preprocess the GTFS data during your app development. You could load it into a SQLite database, and use Core Data to get the data you need out of the file at runtime. This also gives you an opportunity to include only the data that you actually need for your app - it doesn't make sense to ask users to download extra data that they won't need.
Use protocol binary format (pbf) formely google and now open source. It is compact and very fast searchable, so no need to decompress it on a device and load it into a database on that device because pbf acts as a database. Just include pbf library in your code to query it. Of course you have to compress it once before distributing the data online.
i want to make an app which can add the file properties of a song file that the user inputs. Like adding the Album name of the song.. i am still a newbie in android app development...
Thank you.
I assume you're looking to edit the ID3 tags of an MP3 file (other formats, including MP4, usually have a different system for metadata).
Basically, you're going to want to:
Open the MP3 file
Read in the existing ID3 tags from the MP3 file
Populate text views with the data
When the user saves, write the new ID3 tags to the MP3 file.
It looks like there's a fairly old library for dealing with id3 tags in Java, so you might even save yourself a lot of effort going that route.