Libgdx Quiz- Using SQLite Database? - java

I have been learning Android development and using the Libgdx framework for over a month now and want to create a test app. The app i want to create is a quiz and im stuck on the situation on how i am going to store all the questions, answers.
Being a web developer for many years i of course thought of a database but libgdx doesn't have much support for sqlite which leaves me stuck on how to achieve the storing without using a database.
Does anyway know any way to use sqlite with libgdx or how i can achieve this another way, i would appreciate the help, thank you.

I would not go with SQLite in this case. Since it is just a test app and you probably won't have millions of questions and won't need to do any kind of querying, I'd suggest you to use JSON to store your questions.
The JSON support of LibGDX is pretty good and it works on all platforms as well. Have a look at the wiki to see some examples of how to use it.
Furthermore it means that you can easily edit your questions, since it is a human readable file format.

Related

How can I retrieve database data and present it in an application

I am currently working on an application in android studio as I am trying to learn how to use it in my spare time, my knowledge is very low so I was hoping I can explain the concept of my app and ask people for some pointers in different techniques I could use. The basic idea of my app is that it works by allowing people to search for a celebrity and it shows a few facts about them, their date of birth etc. I know its nothing special but it is literally a concept to help me improve my android studio knowledge.
My main issue with this is getting the information from the database into the application in an easy to read and presentable way, what sort of things should I be researching to help me achieve this, from my knowledge I believe I would need to set up a scanner to take the users input, then search the database to find the information and then I need to find a way to return the results in a presentable manner.
Apologies if this is too long winded a question, and thank you to everybody who takes the time to read and respond to me.
If you are looking for some API then check this out this can be help full.
https://api-ninjas.com/api/celebrity
You can even check if Wikipedia have any API for providing info.
I found this also
http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot#APIs%5Ffor%5Fbots
It appears there's also an API for IMDB: http://www.deanclatworthy.com/imdb/

Best practices when learning a new API [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
When learning/working with a new API, does anyone have any tips for effectively learning it?
I currently make a bunch of get requests to understand what I can and cannot retrieve based on the API's responses. From that point I try to map out what is within the API and see what I can build out.
If you guys could share anything what you do that would be great.
The first thing i do is to read API documentation and search for examples in it. As you get used to read this kind of docs you'll find easier to find exactly what parts of the functionality you need to learn first.
I also use search engines to look for more working examples, and after that I work on creating a minimal use case of the API (for example write a file with commons-io api of apache). For this is a good idea to create a project with multiple JUnit tests with minimal use cases of an API (in the example of commons-io create a file, delete a file, move a file, copy a file, ...).
I must say this is not a science and each API is a new world and may require a slightly differnt approach (As with rest apis you'll need to use some tool like curl or postman to understand how to communicate with them, others will have pre-requirements like have a working installation of a system, and so on).
As everything in coding you'll need to do it by yourself and struggle to solve issues you'll find by yourself (what can take several hours of your free time).
There is no "magic" behind learning something, and coding is in some way like playing a musical instrument, it requires practice.
I dont know whether you are a beginner or you have developed already but will start from scratch..!!
Apis are the code which will allow you to play with the content having certain formats...!!
There are apis based on what operations you want to do are.
Get=> In order to fetch something.
Post=> In order to save something.
Put => to update something.
Delete => to delete something.
People also use patch similar to update...!!
You can play around all these by constructing objects and databases...!!
You will require rest services spring restful web service is the ultimate good options..!!
Diving deeper you need to be careful assigning the names you give I mean the meaningful names as you dont know if tomorrow you become famous and need to make your apis sharable ;)
Now some common concerns are like
Meaningful Name.
Versioning is required like what the old apis are working and now what data your apis give.
Can implement swagger its a tool which will allow you to describe the apis like you can write what this api does what type of data it brings etc etc..!!
Apis are more or less called an end points means you have that link as a connection between front end and backend So need to keep it secure..!! By authentication.
Above four points are considered to be good practises for writing apis ;)

Database for android mobile application [duplicate]

This question already has answers here:
webservices on android eclipse
(2 answers)
How to connect Android App connecting to a web service
(4 answers)
Closed 8 years ago.
This is a rookie question at best but here goes anyway,
I developed an android mobile application with eclipse, and my task now is to create a database (quite large) to complete my project,
I spoke to my boss about it because i found a lot of links on the web talking about sqlite databases, but this isnt what's required for this app, the data is not to be stored on the device.
My question is, in the of a android mobile app, what database should i use, which tool, how to access it? I really need help understanding, so if any of you guys has experience in this matter i could use some.
Thanks
As you say Sqlite is about storing in the device. .
It does depend on the complexity/scale of your database.. and also the expertise and learning curve that you or moreover your company are prepared to invest in.
Also where is it to be located? I have just been and am going through this myself and chose Microsoft Azure to host it. There you can choose what you want to do whether you choose a NodeJS approach and then go with something like Mongo DB or set up a 'website' with sql and all those good things.
If I were implementing a simple mobile only app with simple ie not complex storage I would take the former approach. The project I am doing also needs a website and my expertise happens to be sql so I chose the latter. That doesn't mean I couldn't have done the former if I had the time to invest in learning Mongo and node.. which is why it depends:-) Hope that helps.
Ps. Azure is worth a look though as you can get going really easy and it looks like it scales well. Of course there are others to consider.

Best and cheapest way to store users data [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have an app out in the market and planning to maintain basic user data somewhere on backend.
My app is free so I am NOT getting any money from users.
My question is what is the best way to store this data(data has name, email, phonenumber etc.)
One option is to use Google Mobile Backend starter kit but that seems too complex for such a small requirement.
Appreciate your help.
Thanks.
Ok, there are many options you can achieve your goal and these options depends on your proficiency in other areas apart from java and your preferences. Below is just a small list,
Server side language: php, jsp, etc
Database: MySQL, NoSQL, SQLite, etc
Webhost: any free provider (just google "Free webhosting service")
Client side: as you mentioned you already have an app on play store so you will have to update you application accordingly and release new version.
I prefer to use combination of php and MySQL for all my back end work as I feel it is very easy to create and maintain. I also use 000webhost.com as free webhosting service, this service is completely free and also supports php and MySql without any restriction.
First Step I would suggest you is to choose your web-hosting provider, sign up on it and setup your database through PHPMyAdmin (Very easy to do so if you know basic database fundamentals).
Second step would be to create an API according to your choice of server side language (I am assuming you would use php but you are free to use any other language). If you don't know any server side language then you might want to follow some online tutorial and get your self familiar with php (which is again very easy of you know some other programming language). You can simply start from coding basic functions such as retrieving all data and echo them on browser or insert some fields in database, etc. I would advice you to completely code and test all your functionality on normal web browser before you go on about updating you android application and the reason is that once you know what response you are expecting and you have tested it on computer screen it becomes easy to code it for android.
And the final step would be to update your android application, for this well know process is using json strings for sending and/or retrieving data to/from database. If you are only looking to insert few fields in database then you can also use GET or POST methods to send and receive data. And the good news is there are many great tutorials available online for HttpRequest from android you can google it yourself.
Disclaimer: I am not promoting any free/paid service provider in my answer, the only reason I mentioned name is because OP has asked twice for it. If you are thinking of downvoting or flagging the answer for that reason please leave comment and I would delete it ASAP.
I would use a simple php page that captures user data via json from Android and saves them in a MySQL db (technology simple and very cheap, there are many hosting php + mysql free or very low cost);
but if you prefer a java-oriented approach, although slightly more complex
I advise you to Google App Engine that is free (with well-defined limits):
http://www.vogella.com/tutorials/GoogleAppEngineJava/article.html
using the latter you will need to use servlets (do not recommend endpoints) and use JPA to access the database which provides GAE (NoSQL database)

Simplest way to make java crud app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying study web development using Java but its seems very intimidating. all the tutorials are showing very complex methods, even the sample applications that came with NetBeans. I have some experience working with PHP but none with java.
Is there any simple way to use java on the server to just accept post requests and save to database and then display data from database without using things like javaServer faces?
Is it necessary to use frameworks like spring?
Pls forgive if i am asking stupid questions. i cant seem to find where to start learning from and tutorials seem too confusing.
Links to any good article will be very helpful
Thanks
For this purpose you should be familiar with the Servlet API, and preferably also with MVC frameworks and so on.
For the whole world to be a bit more straightforward for you and to steer away from the average-PHP-community-drawbacks (e.g. nobody tells you how to code well), I'd recommend to read THIS book.
But first of all, start HERE and then move on to THIS SITE.
The other way around (talking about DB access, not the web service here) is using raw SQL via JDBC which I won't recommend unless you have a good reason for it and you're already familiar with using a DB the right way (mysql and mysqli libs of PHP won't necessarily drive you the right path; PDO most probably will however).
Of course you don't necessarily need to use frameworks, but you're (actually in any language) way better off using them. Yes, probably the closest thing to the "nobrainers-php-methodology" (mindless coding; wiring UI, DB access and business logic together in a single file; etc.) is using the Servlet API, and then through a java.sql.Connection send your GET/POST data directly to the DB via JDBC. But doing so is slightly worse than cruelly murdering cute little squirrels/bunnies/kitties/insert_your_favourite_cute_creature_here
You'll also need a servlet container, most common of which is Apache Tomcat.
To learn Web Developing with Java Play Framework 1 is very nice:
Step by Step guide for a cool blog: http://www.playframework.com/documentation/1.2.7/guide1
Documentation: http://www.playframework.com/documentation/1.2.7/home
CRUD module documentation: http://www.playframework.com/documentation/1.2.7/crud
You get compile feedback directly in the browser.
Run your tests in the browser.
No redeployment to containers necessary/hot deployment.
No servlets.
Play 2 is already around, but going through Play 1 is much simpler if you are new a the Java world.

Categories

Resources