OK so here's the deal. I'm developing apk and I'd like to add database (atm at .txt) so my question is:
How should I add it to my apk, just load it all to table or there is any better way to do it?
And after that I'd like to click on button and be able to start writing item from base and phone would help out. For example I've got in database chicken breast, chicken leggs, eggs
and when I write "br" my apk shows most accurate position.
ps. my database got about 3k positions.
If you want to access a file when creating an app you can place it in the assets folder inside of your project. You could then call Context.getAssets().open("FILENAME") to access it as an input stream.
You might want to consider a sqlitedb instead of a text file,The following tutorial can assist you in setting up an android project using a sqlite db.
http://www.vogella.com/tutorials/AndroidSQLite/article.html
Related
I followed this tutorial. Link-
I successfully implemented what's in the tutorial.
After that I Use Update command to update my DB from the asset folder.
In my device i can see The updated part,
But when i Import the DB File to SQL DB Browser, the DB File remains unchanged.
I need the DB File for other use so im using Android to fill the datas what i need. Thanks.
If you want to ship your Android app with a populated DB, then you should definitely use the sqlite-asset-helper by Jeff Gilfelt. You can find a real example of how to use the library here: http://www.6020peaks.com/2015/03/how-to-ship-an-android-app-with-preloaded-data/
Update: I just saw that the tutorial you followed is also using sqlite-asset-helper. If I understood your question correctly, I think you are looking at the wrong db file. The file that you need and that will contain all the new data generated by your android app will be here: /data/data/application_package_name/databases.
Check this out for more info on that direction: What is the default database location of an android app for an unrooted device?? Is it same as for rooted one?
I was wondering if it is possible to easily add data to existing database in Eclipse. I have a database with about 1000 records, and I don't want to put them in by hand. (In my 'update'-activity.).
I've already tried to go to DDMS - data - data - (project name) - databases, and replace the file for another file with the same name. When I do that, I get an logcat error saying:
12-15 08:47:33.495: E/SQLiteLog(4564): (26) file is encrypted or is not a database
12-15 08:47:33.495: E/DefaultDatabaseErrorHandler(4564): Corruption reported by sqlite on database: /data/data/com.jacob.eindproject/databases/Voedsel
12-15 08:47:33.495: E/DefaultDatabaseErrorHandler(4564): deleting the database file: /data/data/com.jacob.eindproject/databases/Voedsel
I can 'pull a file from the device'. Can I add data then? Somebody has an idea?
Thank you all in advance,
Jacob
Unless you will be the only user of your app, pushing data to the device or emulator manually is useless. You cannot do that for thousands of users, if for no other reason than they are unlikely to mail you their phones so you can connect the USB cable and push the file.
If your objective is to ship an app that contains starter data for the app, I recommend SQLiteAssetHelper. This is a subclass of SQLiteOpenHelper that can automatically unpack a database bundled into your app when the database is first needed.
I have made an android app and I have some .csv files with initial data. Can anyone suggest a proper way to do that? For example, someone could say "just create a folder and put them inside" but I want a better way like a setup that I can do with windows (e.g. installshield but no so advanced ).
You can make with wizard forms. In first window choose .csv file, in second window
match the fileds of .csv file with database fildes and finally upload data.
i'm trying to deal with Android since few weeks. And i'm now trying to access media databases files like photo, music, videos,settings,installed applications stored in the phone. What's these files paths?
I've already find contacts, bookmarks, sms files under "/data/data/com.android.providers" structure.
Can someone tell me the whole database structure?
your databases are under /data/data/[your package name]/databases/[your database name] although you should usually not be trying to access these
edit
adamcodes is right, corrected
I've only just started to write in Java on Android, so please bear with me.
I have some settings I want to hold in my app, normally I would have used an xml file. Trouble is i'm not sure how to load it into the xml parser to read it.
I thought I might be able to drop it into /res/values/Info.xml and open it from there but it does'nt find the file.
I have also read that people are starting to use a SQLite database to hold information in, is this more the standard way to go?
thanks a lot
Luke
It sounds like what you want are Shared Preferences. Its a simple way of storing key value pairs, along with a UI for letting the user change them.
You could try storing to External Files (that way they can save settings on an SD card if they have 2.2). You wouldn't be able to modify the files in the res folder like you tried because these files get compiled into the app package. You could also try Internal Files found on the same page. SQLite might be a bit much for config settings.