Can I use an sqlite database created for ios in android? - android

I would like to access the string-files stored in an sqlite database created for an ios application.
Any suggested methods to do this? I have searched all over the net but have not found anyone who has done this.
I know it is possible to convert a plist file to an xml file, but in the future the app I am working on will get all the resources (including strings) from a server.
I hope someone can help with this.

You could just include the SQLite database file as an asset in your app then use it like any other SQLite DB in Android.
You then mention that you will get resources from the server and I assume from your question that the data is currently in pLists so I think there may be 2 questions in one?
You might consider using JSON which, in many cases, is much faster than parsing XML. I recently used "Sublime Text" to convert a bunch of plists to JSON. It did a great job. v1 of my app parsed pLists. I tried SAX, DOM and the pull parser to find the quickest (SAX in this case) but, after conversion to JSON, v2 of the app is much, much faster. I haven't measured it because I don't need to. The user experience is enough. Where I previously had to use a loading progress dialog on a particularly large pList, with the new JSON parser, the UI is responsive at all times.

Related

JSON image to sqlite Android programming

I am new to Android Programming and would like to ask about JSON/sqlite. I have already parsed JSON text and store it in sqlite and then displayed the data in a listview in my app. However, I didn't parse the images in my JSON file (started with the easy part first). Now I have to do the image parsing and I have looked through many websites but still feel too confused about how to do it.
In the following link
http://www.androidbegin.com/tutorial/android-json-parse-images-and-texts-tutorial/
I have looked at how they do the image parsing but they're caching the images while I have to store the data into DB. In the link there is ImageLoader.java, MemoryCache.java, FileCachee.java,and Utils.java; these classes made me even more confused, do I need all of these for the images?
Can anyone please guide me like what steps I should follow? which classes of these do I need and which are not necessary?Or any kind of help.
Thank you in advance
To read in a single image, no you don't need all that. All you need is to read in an array of bytes (the contents of the file) and turn that into a Bitmap object. What all that is useful for is to hold lots of images at once- to make sure you don't use up too much RAM (MemoryCache), request them from the network more than once (FileChace), and to manage all of those (ImageLoader). So if you want to download lots of images its useful. For a single one its overkill.

Android, storing big number of small images linked to database

I have been asked to create a tiny android app.
In everyday work i code for .NET and I have no experience connected with Android, but as it is a really small app I guess it's going to be a good experience rather than something hard.
The core of the app would be a small database (probably XML, unless somebody suggest better solution) that would contain categories, names of the institutions assigned with each category and logo (not very high resolution I guess a single file would be <100kB) of the institution.
The database also would not be very big - I expect not more than 1000 records in total. The DB has to be totally offline and local, it cannot require Internet access when operating.
The model I assume would be to ship new version of the application when the database changes (which is not going to be very frequent).
What is the best way to deal with these requirements?
My first idea was to create an XML file that would contain the records and link to the image. The XML and all the images linked to it would be stored in single file (preferably zip) that would be stored in app resources. This is very good as it is going to be very easy to update the database.
The second idea that somebody suggested me would be to use SQLite and store images in BLOB. In general I have read that it isn't a good idea to store images in database directly, and I am afraid if it's going to be possible to meet all requirements mentioned above.
Mostly I have no idea how to update the database easily and attach it to new version of application.
Any suggestions?
I would be grateful for any response.
I wouldn't go about using XML to save your data and by no means zip anything.
I think your way of thinking is ok, but you're making things really complicated for yourself.
Seeing as you're used to .NET I suppose you're also pretty confident with SQL, so I'd suggest you have a look at how to use the built-in SQLite database in Android.
If you would go the XML route you'd have to serialize and de-serialize the XML file over and over again and then parse the XML. Ok you don't have a lot of data, but searching inside an XML file with at least 1000 nodes would be slow in comparison to the performance of a database.
Also upgrading an existing SQLite database is not that hard - Android has methods for that (onUpgrade coming from the SQLiteOpenHelper).
As to saving images I'm assuming that you won't fetch new pictures from the Internet, so it would be best just to store them in the drawable folder of your app (be mindful of different screensizes) and then reading them into an ImageView when needed. To figure out what image should go for what institution I would store either the image name of each image in the SQLite database or store the resource id for each image in the database - for instance R.drawable.myawesomepictureformyinstitution.
I know my answer is somewhat "superficial", but your question is also somewhat "broad" and hard to answer without me actually writing most of the code, and that's not my intention ;-)
Hope this helps - let me know if anything is unclear.

Load large amount of data to DB - Android

I'm building a new application to the Android platform and I need a suggestion.
I have a large amount of data that I want to import into a sqlite DB, something like 2000 rows.
My question is what is the best method to load the data into the DB?
Two ways I think of:
An xml file that holds all the data and then loads it with DocumentBuilder object.
A CSV file, and loads it with String Tokenizer. Found that post.
I want it to be with external file because When I release an update I will replace only the that file.
I want something that would be efficient as much as possible - all the data will load at the first startup of the application and I need it to be fast.
Any suggestion would be great.
Thanks.
Use InsertHelper to do a bulk insert.
Take a look on this other question
Instead of XML or CSV files, you can directly use an external sqlite DB you prepared in your computer. This technique is explained here: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
It really does not matter - you can achieve good perfomance with both approaches. With XML you can use some databinding, making programming easier (marginally). You may also consider JSON as transport format.
When parsing, keep in mind that building complete object tree in memory ( like XML DOM parser) consumes a lot of memory and results in a lot of allocations - pull parsing model like XPP / GSON is preferable.

Passing multiple sqlite rows to mysql?

I was brainstorming how I should handle this. This is how the application is going to work:
User enters multiple pieces of data into app
App stores data into SQLite database
User hits SYNC button and app will pass all new/updated/deleted info to site PHP and update MYSQL.
I was thinking I can do a loop where it sends (and receive) one row at a time to mysql or I can use a string builder to build a XML, and pass (and receive) the XML string to PHP to process. The xml will have tag data specifying if the element is to be added, deleted or updated.
I figure the XML is a better option, but I'm coming here for opinions how I should push multiple rows to be added/deleted or updated to my MYSQL because I feel there's probably a more efficient/easier way of doing this.
Thanks!
--UPDATE--
Here's some helpful links I found of JSONArrays for those seeking similar information as I am about Android SQLite to PHP MYSQL.
Nice tutorial about JSONArrays in PHP: http://webhole.net/2009/08/31/how-to-read-json-data-with-php/
Another tutorial about JSONArrays in Java: http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/
Ah, opinions. Painful things though: everyone has one and everyone thinks their opinion is better than the next persons'.
I've implemented a system that is pretty much identical: I used JSON for it though. There is no intrinsic issue with using XML: whatever translation layer you are comfortable with is probably fine. JSON was (for me) a bit more compact than XML, required less code on both sides (json_decode is your friend) and seemed to me to be an easier row to hoe than using XML. However PHP's simplexml would probably work fine as well.
If you're doing this from scratch you might want to look at one of the systems with automatic data syncing like Mobile Couchbase (see http://www.couchbase.com/products-and-services/mobile-couchbase): would require a fair bit more tooling and a bigger server/client resource footprint but might get you there faster.

How to storing data in my own application

I would like to build some simple application - for example Todo list - and I am thinking about the problem and its solving - how can I to store data in my own application on Android platform?
I should to use some text file, xml file or some database? What will be better for beginner on this field?
You'll have a VERY hard time getting anywhere with Android if you don't read through their website/dev resources. I would highly recommend visiting their site.
As far as data storage is concerned, that varies based on your need. Explained here
My suggestion is to use SQLite that comes with Android. http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
In my opinion, a SQLite database seems most appropriate for this kind of application. There is lots of support for using the SQLite database in conjuction with ListViews (which I imagine you'd want to use in your to-do list app).
In case you haven't already checked it out, see the page on the developer site:
http://developer.android.com/guide/topics/data/data-storage.html#db
Theres a few ways you can store data. I've created a few applications thats store data using shared preferences
They're quite handy for storing strings, ints, bool values etc. However if you have a large scaled application, that requires better database management, I would look into sqlLite.
Android has supported classes and functions to help access/store the information.
Theres a good tutorial on the android site called notepad that takes you through how to use sqlite.
That should get you started :)
Look at this Thread klick
Edit: its cool for less data, if you want to store and browse lots of data, you should use as SQLite Database
Using a file, database or xml based depends entirely on what kind of application you are building. For eg: If you parse an XML feed and store the results back in an XML file - it totally defeats the storage purpose!
Databases are used to store structured and related content like - news feed results, email client data, etc.
Files are more used for storing raw / binary content like storing images, attachments, etc.
BTW, if you are a beginner - you should try all of them! :)
Hope this helps!

Categories

Resources