I have been studying Java for a little bit now, and I'm ready to try building something. I think I have the basic understanding of how to build simple parts, but I have a hard time planning out my project. I was hoping you guys could tell me what I would need to make it work.
I am creating an app for work. I work in the ATM business, and we provide tech support for all ATM models. So we have a master list of atm error codes, what models they apply to, their descriptions, and solutions.
From the App I would like to make it searchable by ATM manufacturer->Model->List of error codes to choose from. AND searchable by error code.
What I'm not sure about is how to save such a big list of codes. I've got them formatted like this:
("Hyosung", "1000", "20001", "Unable to Detect Cassette", "Remove and replace cassette - Check the micro-switch located on the inside left wall")
(MANUFACTURER, MODEL, CODE, DESCRIPTION, SOLUTION)
So depending on how the user chooses to search, it could pull all error
There are, maybe, 1000 error codes. Would it be best to save this to a text file that the app can access? How would you guys manage the error codes?
Store it in a SQLite database. It might be a slight overkill in this case, but it's flexible enough (and you really should learn about databases anyway).
Your error codes seem to be in CSV format. So:
On first use of application parse CSV file line by line using one of CSV parsing libs: http://opencsv.sourceforge.net/
Save every line of data as a row in database: http://developer.android.com/guide/topics/data/data-storage.html#db
Create a simple GUI where you enter error code and it returns all data for this error code.
Related
as part of a university project, i have to build an android app that will contain informations about diseases, the diseases will be listed in a list (alphabetic order), when clicked on a disease you'll be directed to another layout that contains informations about the disease chosen (including text and images).
i'm new to this and i don't know how to approach this app..and for the text should i build a database or directly input the text inside the app or something like that .if you know a tutorial or something that would help please share
Ps: there is almost 60 Diseases and each disease will have a subitems (causes, treatment, clinical signs .)
thanks
First of all, the comments are right. Please be more precise in your question. Ask what specific problem occured, if possible provide code samples, errors and research state. https://stackoverflow.com/questions/how-to-ask
UI Design (List)
there is almost 60 Diseases and each disease will have a subitems
Therefore I would suggest an ExpandableListView.
Check out this code sample: https://www.journaldev.com/9942/android-expandablelistview-example-tutorial
Afterwards if the user clicks on an item, you open another Activity with details
Data Storage
should i build a database or directly input the text inside the app or
something like that
Static approach
As you can think of, putting data directly into views makes it difficult to maintain, but is faster implemented and less difficult.
Implemenation: I would suggest putting the data into res/raw as a .json file. In your code, build a JSONObject out of it and pass it to the ListViewAdapter.
Dynamic approach
You need Internet permission, a webserver and a remote database from where you can query the data.
Implementation: If you have a hosted webserver you probably have PHP and MySQL databases. Create a table, fill it with data and build an API in PHP where you provide the data from the database. If you have a VPS or dedicated server you can use MongoDB which works with JSON out of the box.
My guess
For an university project, use static. Otherwise dynamic of course.
Hope this helps
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.
As a preface to this question, I should make it known that this is my first non-trivial Android project. I have a reasonable background in programming, but am new to the platform. I'm working on a friend's app, which has been built up by numerous other parties before it came into my hands. What it is is a foraging guide made up of pictures and all sorts of information regarding identification, uses, poisonous parts, and so on. Users don't insert any information of their own -- it's just a big searchable library, basically.
Here's my issue: Right now, all the information is coming from multiple XML files in res/raw/, corresponding to different categories of information (ie: Plants, Recipes). There's an XML parser that's been implemented, ostensibly to read the contents of the XML files and then populate lists of objects corresponding to the aforementioned categories. Each category is defined in a class of its own, and there are 6 such categories.
My job is to change all this over to read from a SQLite database, which my friend has already created. Now each category corresponds to a table in the database, and the columns of the tables correspond to various bits of associated information. It all looks quite straightforward.
Using one of the many easy-to-follow tutorials online, I thought I'd been successful in basically replacing the XML parser with a database helper that worked by opening the DB and populating category lists with tuples from the tables. I felt like I wouldn't need to substantially modify other parts of the code in order for the data source switchover to work.
I thought it worked because I removed the XML parser, and it compiled and produced the same result on my test device. However, I realized I was wrong -- when I removed res/raw/, the app crashes. After re-cloning the project to check, it in fact seems that the XML parser isn't even needed at all for the XML data to be read perfectly well into the program! So I'm obviously missing something important with regard to where/how this XML data is being integrated into the app. The XML gets read in whether or not the parser is present, but if the XML files are removed, the app crashes.
It looks like it should be so easy to just dump tuples in as objects on a list and then let the existing code deal with them as they do. That would let me avoid substantially reworking the rest of the code, as it intuitively seems unnecessary.
Can anyone explain a bit about how the XML resources are working, and why the app runs just fine without the parser? Like I said, I'm shy of messing around too much with what's already in place. Basically I need some suggestions on a strategy for carrying this out, but haven't been able to find anything.
Thank you so much for any help you can give me.
If I understand correctly, when the app starts it populates database from the xml files. If so, when you delete the files and start app it should crush since there are no files anymore.
What you can do is prepopulate database file from xml files in some other script/program. Then copy the database file into assests folder. Now you will not need xml files (so just delete them) and use your db file.
I am developing a glossary using the sample code Searchable Dictionary. Thanks to searching here, I have figured out how to update the database, which is a .txt file, and then get it to load by changing the version number in Dictionary.java.
My question is, how to do the following:
I would like to be able to insert illustrative images into the definitions.
I would also like to insert links to other entries in the dictionary (e.g. 'inventory' should have a link to 'product flow' and other related terms).
I would also like to know how to insert a carriage return.
My original glossary in spreadsheet format has several fields: 'term' 'definition' 'example' 'related terms'. I want to be able to put in links and images inside these fields and have a couple of carriage returns in between each field to differentiate them.
The dictionary code seems to take in everything as a string, so even if I try to put 'image.jpg', or '\n' for a new line, it simply prints that as part of the string. Is there a way around this?
Searching stackoverflow gave a few links to using SQLite. I am honestly a newbie at all this; the last time I programmed anything significant was ten years ago. Rewriting the code to directly access a SQLite database would be nontrivial for me. So I would like to know if that is really the route I should be taking. If it is, then could you point me to the most simple tutorials for constructing a dictionary that way? I downloaded SQLite data browser, but haven't figured out how to use to construct a new database. I know it should not be so hard; I just don't know what I am doing. :(
If there is an easy way to just do it inline, still using the Searchable Dictionary sample code as a base, that would really make my day. Otherwise, any specific suggestions/directions would be really appreciated.
Thank you!!
Update:
For clarification, below is an example of one entry in my glossary, as desired. There are carriage returns between sections, and links and images are inline with text:
Heijunka, or Load Leveling - An approach to smooth production flow when a mix of products is to be produced, by identifying for a selected time period, the smallest batch size at which to produce each specific product in the mix, before switching over to make another product in the mix.
Example:
Keeping a steady work flow, even if much slower than the original max, reduces waste (<-this is a link to the entry 'waste' in the glossary):
[image of line of balance graph with load leveling, and without]
Related Terms: work structure, demand leveling (<-These are links to respective entries)
Not sure if you saw this already, but Android has some developer lessons for saving Key-Value sets for simple data, and saving to SQLlite for more complex structures.
It sounds like your app needs a database called "Invetory" with the following fields: "ProductImage", "ProductTitle", "ProductLink". And you want to store the image as a BLOB. There's a good SO post on how to take an image from a URL and convert it to a byte array for storage: how to store Image as blob in Sqlite & how to retrieve it?
For the carriage return, i'm assuming you're using "\n"? If that's not working have you tried unescaping your string for TextView:
String s = unescape(stringFromDatabase)
Or for SQLlite:
DatabaseUtils.sqlEscapeString()
Key-value data: http://developer.android.com/training/basics/data-storage/shared-preferences.html
SQLlite data: http://developer.android.com/training/basics/data-storage/databases.html
Additional SQLite resources:
http://www.youtube.com/watch?v=G8ZRXdztESU
http://www.vogella.com/articles/AndroidSQLite/article.html
this is my first app and I am trying to help out a business that I work for. Basically I picked up Android Tablet Application for Dummies and have been using it as reference. I am making a sort of time card application for a business I work for. My goal is that I want to take the information that the workers would enter in over the course of the day, and have them email it to the person writing payroll. Is there any way for me to just email the database with all of the contents? Or a simple way to send the contents in another easy to read format? Open to all suggestions and alternatives, thank you for your time!
A raw db file probably is not going to be terribly useful for the payroll person.
If I were you I'd make something that will query your DB for all rows, once you have the resulting cursor you can iterate over it and put the data into some more useful data format.
The data format you choose depends on your situation. XML or CSV seem like good options. CSV perhaps a little bit better since it would be able to be opened in Excel (which anyone in payroll probably has access to)
You could also make your own data format if you want. Some sort of plain txt flatfile would be easiest, and it would be very human readable (Easier for payroll employee)
something like this:
IN Mike 2:31pm 6/14
IN Joe 2:45pm 6/14
OUT Mike 4:55pm 6/14
etc...
Then if you were nice you'd make something to go at the end that will tally up total hours for the day and/or pay period
Total Hours for period
Mike: 25.4
Joe: 22.3
etc...
EDIT: There are many examples of CSV all around the web.
Start Here to learn what it is.
Once you understand what it is you'll need to learn how to implement the read/write in java. You can do it with plain java using strings fairly easy. But there are also some Libraries out that that make it a whole lot easier for you to interact with CSV data.