How to make MCQ test functionality that loads data from server - android

I am working on learning application. I want to add MCQ test functionality in my app. I want to load data from the server when the test started. and it will not call to the server for each question because it will slow down test process. I want to load all the question when the test starts and a new question will appear only when clicking on next question button. There will be four option in each question so at the end I want to send data to the server to verify the answer. I actually confused in what should I used to save question in internal memory. and then their answer to submit to the server.

Android developer guide has an explanatory list of available options for storage that you can leverage. Since you would want to keep this information secure. I suggest you should use one from the list below
Internal file storage: Store app-private files on the device file
system.
Databases: Store structured data in a private database.
Although a lot depends on the size of data and other specifics of your use case.
Based on the discussion in the comments. Here is a cool answer to the same, i.e serialize/deserialize the objects.

Related

Approaches to storing data in Android

I have started learning Android development and I have a very newbie question. I understand that Android can store data in SQLite for example, but what other approaches are there to the storage of data within your application?
Do Android apps ever have data 'embedded' within the application, in which case what sort of data structure or concept would this use?
I am thinking of a scenario where the data is static but is perhaps not a large enough dataset to warrant a database..e.g. an app with general knowledge questions and answers
Any guidance much appreciated
Rowan
Yes You are correct You can use SqLite Database for storage
other ways to store data is SharedPreferences
But in your case you wanrted to save questions and answers which is static one so you can create a text file and put that in your assets folder and you can read that file as any other text file in java
Refer this link how to read file from assets folder
1.Sqlite Database
2.Shared preferences
3.Internal memory
4.external memory i.e sd card
i would suggest you to go with Database. as it will let you store as much data as your app needed, There are some other option also present like
Sharedpreference i.e. cookies in general term. It let u store only few KB data and not good to store much data. When u retrieve data from cookies. All data will be store into ram and use app memory. that is use less when u do not need all data to retrieve and store into ram and then remove
Store into file and ship that file with your app. Yeah. this could be better idea again. you need to read it byte by byte. and hence reading to mid or last line will store all data into ram and hence will take memory.
Use Web Service to download data. It will let you store Large data and you have to download using Web APi. Hence it could be better idea. But this requires active Internet connection to play game to run app.
There must be some other option also present. You can search. surely you will find them :)
Overall Database it good solution for all app. As it will let you do search store delete and let you do other operation in less amount of memory. In Mobile Development Memory is very Important thing we have to take care of.
Let me know if you have other unclear thought.
item
You could also store info in a server.
Pros :
You can change the content without needing user-side update of the app.
Cons :
Your app (mostly the UI) would need to manage connection problems.
You may need to implement async tasks for querying data from server.

Should I use arrary or sqlite database? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm seeking assistance on a APP I need to create. I don't have no experience with android app development but, I'm studying and practicing.
I'm trying to build an app to record payments from a list of customers and print a receipt when paid. I download a list of customers with pending balance, using json array into android. Now, I'm confused, don't know if I should use arrays or a database to store the list, since I need to update (upload) later to the server. SQLite seems like an option but, I have to download the list every time user is connected to WiFi.
I guess I have to store the payments on an array and flush it once uploaded.
Can you please tell me what would be the best option for the tasks I'm trying to accomplish.
It depends on your use case. Arrays and sqlite can work independently or together.
If you are going to upload the data instantly after downloading within the same session, then you can keep it in the Array and upload it after what ever you need to do with it. Keep in mind that Arrays will be kept in memory and depending on where you are keeping the array object, they might not persist through the life cycle of an activity or the life cycle of your application.
SQLite on the hand writes data to disk, so you will be able to persist it even after user has backed out of your application.
...since I need to update (upload) later to the server
Based on the above, it seems like you should persist your data on disk. SQLite is one of the options for persisting data. Have a look here to see what else is available for persisting data.
You can load up any persisted data into your array and upload it after you have processed it.
Hope this helps.

ASP.NET Registration Form to a Simple Offline-capabled Mobile Application

My question will be really long but I encourage you to read through everything as it will be used for an honest, good cause. Or you can skip to the highlighted questions part.
Let me introduce myself first, I am an independent web application developer here in the Philippines and I work for a non-profit organization where we help less fortunate people by providing IT solutions and services for free. I have a working web application that has dynamic registration forms where users can enter their data online. I developed this application with responsive UI using bootstrap's grid system. But being here in the Philippines, there are remote areas where the target clients don't have access to the internet 24/7, and bringing laptop or desktop computers is a pain because of the terrain and rivers that we need to cross to reach these remote areas.
Now, together with my team, we are thinking of a way to use our mobile phones, mostly androids to create a mobile app version of our web application. Where it can download the registration form (html) when we are connected and then use it even without internet connection.
Ideally the situation should be:
1. Launch the app from my mobile, and while connected to the internet, download the html forms needed from our web application.
2. Travel to remote areas, use the mobile application to encode the native's information offline. (I heard its possible to save it locally to sqlite db)
3. Go back to the headquarters and sync with the online web application to pass all the information gathered and thats it.
Having said all that, I have 3 questions:
1. What should I use to create a mobile app that can display html forms downloaded from the internet?
2. How can I save the data locally (within the phone)? I heard about sqlite db but I am not sure if it will work with my situation.
3. How can I sync the locally saved data to the online web application?
This is more like a survey application. You dont need the html here. You design your question definitions in xml or json. You may have multiple types of question like Text Answer Question, Single Choice Multiple Option Question, Multiple Choice Multiple Option question, Image Question, QR Code Question, GPS Coordinate Question etc etc. You design these questions in json or xml and put them in server. For example
{
questionSetName: "Question Set 1",
question:[{
questionText: "What is your name ?",
questionType: "TextAnswer"
},
{
questionText: "Which one console below do you own ?",
questionType: "SingleChoiceMultipleOption",
options:["PS4", "XBox", "Steam Console"]
}]
}
Now for your mobile client:
When online user will want to download questions for later offline surveys. so user send a request to server for available question sets. then will pull these file from server (in case of android through some HttpClient like OkHttpClient) and put them in sd card. The server will implement rest apis for question lists and downloading individual question sets.
The application will check if files are present in a certain folder (your app designated folder) in the sdcard. The file names will be the list of the questions.It will parse the json or xml and render question windows accordingly, for example for text question a label with the question text and a text box for answer, for single choice multiple options a set of option buttons, for image questions open the mobile camera etc.
When filling up (answering) the questions you save the answers and question number and flush them in a json file. and put the answer files in another directory (you need some sort of identification).
later on upload the answer files to server.
The server side will require the following rest apis :
1. List of Question Sets of a user (from db ??)
2. An api (webservice) to download a set of questions.
3. An api to upload an answer sheet for a question.
4. user management of course.
Hope this helps.

How to list my app downloads

I'm working on books library in my android app... so I want to add a functionality that allows the user to view the books that he/she has downloaded by my app..
any idea or hint to work this out?
The final solution depends a bit on the details you want to store for the books. If you only want to store the book title and author and you don't want to deal with a database yet then SharedPreferences might be an option. But they are more like Java Properties files and with this said not a good solution for persisting more complex data structures.
If you want to store more metadata of the books (e.g. the current read position, bookmarks, etc.) then you will need a database sooner or later. I recommend thinking about the data model first and then start with the SQLite database included in Android.
You can find more details here Android Developers - Data Storage
One of the way to keep track is whenever a book is downloaded store the required data in database and retrive it whenever required or delete it from database if no required in future.
Try this way.
If your app has already downloaded books, then you need a ListView to display them.
If, however, the problem is both in saving and listing, you should read the dev guide, esp about using File and getExternalFileDir.

which kind of database to use with android app?

I am developing an android program for my university. I am confused about which database to use.
What I want is that when the user is connected to the internet the program will check for any updates in the backend database. If there is any, the program will sync it with Android device.
Let's assume that after while the user opens the program in place with no internet, the program will work just fine because the file is already in his mobile.
I chose Access and created .xml file and by the help of this site: XML resources in android. I learnt how to read it.
Actually this program is my senior project. I dont want the judges to ask me why didn't I use MySQL or SQLite.
Which database system should I use? Is Access the right database system to choose?
I want to do a program that looks just like Univ of Kent program.
Parsing XML could take time, also in XML you have no choice but to load the whole file.
SQLite is fast, simple to use and very dynamic.
Android offers a very simple SQLite API. Androoid SQLite API
If you are interested in reading more about all the data storage types in Android visit this link
It depends upon your requirement. lets say you want to build something which handles and stores the data on your device locally then SQLite is a good option (you can use firebase as well).if you want to do some sort of calculation on you data on a remote server then firebase is a best choice .
by using firebase you can store your data generated by your users and then if you want you can carry out some analytics as well.
i would prefer Firebase .

Categories

Resources