logo

Android Quiz Contest App Code

This assignment requires that as a group you undertake to analyse, design, develop, test and deliver an Android App. The App does not need to be overly complex, but your developed app, if it is to have any future value, must serve some well-defined purpose.

27 Pages4598 Words469 Views
   

Added on  2023-04-22

About This Document

Get the complete code for Android Quiz Contest App developed using Java and SQLite. Download the source code for free from Desklib and learn how to create a quiz app.

Android Quiz Contest App Code

This assignment requires that as a group you undertake to analyse, design, develop, test and deliver an Android App. The App does not need to be overly complex, but your developed app, if it is to have any future value, must serve some well-defined purpose.

   Added on 2023-04-22

ShareRelated Documents
1. FinalActivity.java
package com.example.quiz_contest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class FinalActivity extends Activity {
TextView tv,tv2;
private SQLiteDatabase db;
private Cursor c;
Button btn;
int s;String n,query;
private static final String x="SELECT * FROM scores";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_final);
tv=(TextView)findViewById(R.id.textView3);
tv2=(TextView)findViewById(R.id.textView2);
btn=(Button)findViewById(R.id.button1);
Bundle data=getIntent().getExtras();
s=data.getInt("score");
n=data.getString("Name");
tv.setText("Score: "+s);
createdatabase();
c=db.rawQuery(x, null);
if(!c.moveToFirst())
{
Android Quiz Contest App Code_1
query="INSERT INTO scores VALUES('"+n+"','"+s+"')";
db.execSQL(query);
tv2.setText("You got a high score!");
}
else
{
c.moveToLast();
if(s>Integer.parseInt(c.getString(1)))
{
query="UPDATE scores SET name='"+n+"', score='"+s+"'
where score='"+c.getString(1)+"'";
db.execSQL(query);
tv2.setText("You got a high score!");
}
}
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i=new Intent(getApplicationContext(),
HomeScreen.class);
i.putExtra("Name", n);
startActivity(i);
}
});
}
protected void createdatabase()
{
db=openOrCreateDatabase("ScoresDB.db", Context.MODE_PRIVATE,
null);
db.execSQL("CREATE TABLE IF NOT EXISTS scores(name
VARCHAR, score NUMBER)");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_final, menu);
return true;
Android Quiz Contest App Code_2
}
}
2. GameStart.java
package com.example.quiz_contest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
public class GameStart extends Activity {
RadioGroup rg;
TextView tv;
Button btn;
Android Quiz Contest App Code_3
private Cursor p;
String n;
private SQLiteDatabase db;
String q[]={
"How many yards are there between wickets in a game of cricket",
"Which is the largest planet in the solar system?",
"Which of the following is a palindrome?",
"The word ISPISISPSMI is an anagram of which of the following?",
"If David travels one mile north, two miles west, one mile north, one mile
east, three miles south, one mile east,how far will he be from his starting point?",
"Which of the following words is most associated with the word
INTERMITTENT?",
"What month was last month if February is in three months?",
"If the word EWE is written above the word ZOO and the word TOE is
written above the word EWE, would the number TWO appear diagonally?",
"Mia and Tilly have the same amount of sweets each. How many sweets
should Mia give Tilly so that she has four sweets more?",
"Which of the following is least like the others?",
"Including the white ball, how many color varieties are used in a game of
snooker?",
"Which body part can be placed before the following words? drum ache
ring",
"Which continent has no active volcanoes?",
"In the fairytale Cinderella, what did Cinderella leave behind as she was
leaving the ball?",
"What year did the American Civil War start?",
"Which country will host the 2016 Olympics?",
"Which season would the fall be known as in Great Britain?",
Android Quiz Contest App Code_4
"Which is not among the three primary colors?",
"What is an expression of language meaning the opposite?","What is the
primary religion in Thailand?",
"Which is the only body organ able to regenerate itself?","Complete the
saying: A picture is worth...?",
"Dos is Spanish for which number?","How many hours are equal to 600
minutes?",
"Can you unscramble this word to find the name of a country: SUSAIR?",
"What is the meaning of the Latin phrase ‘bona fide’?","What do the fifty
stars on the US flag represent?",
"Which country is first to appear in the English dictionary?","What is the
last letter of the Greek alphabet?",
"What name is given to a triangle with one angle greater than 90
degrees?",
"What is the name of Scooby Doo`s psychedelic van?","What is the
largest island in the Caribbean?",
"Which TV series features a chemistry teacher called Walter White?",
"Which F.R.I.E.N.D.S. character makes jokes when he is
uncomfortable?",
"If you were born December 4th, which star sign would you belong to?",
"In the film Shrek, what is the name of Shrek`s wife?","What was the
name of the boy in the Jungle Book?",
"What is the name of the actor who played the role of Harry Potter in the
film series?",
"Which Bond movie did Daniel Craig first star in?","Who played Jack in
the film The Titanic?",
"From which movie did this quote come from: A lie keeps growing and
growing until it is as plain as the nose on your face?",
"How many square meters are there in a hectare?","How many rings does
Saturn have around it?",
Android Quiz Contest App Code_5
"Which of the five senses develops first?","How many carats are there in
pure gold?",
"Who scored the winning penalty in the 2006 world cup final?","How
many red balls are used in a game of snooker?",
"Who has won the most FIFA Ballons d Or?","In which sport is the Davis
cup awarded?",
"At what time did Andres Iniesta score the winning goal to help Spain win
their first World Cup ever?"
};
String
a[]={"20","Pluto","yatch","Plant","Zero","Continuous","October","WWE","4","Length","6","Ea
r","Asia","Earring","1857","Argentina","Autumn","Red"
,"Similie","Hinduism","Tooth","many words","22","20","Uruguay","in
good faith","Presidents","Argentina","Omega","Obtuse","The Mystery Traveller",
"Cuba","Prison Break","Ross","Gemini","Alice","Timon","Daniel
Radcliffe","Spectre","Christan Bale","Toy Story","10000","4","Touch","22",
"Andrea Pirlo","12","Cristiano Ronaldo","Football","117"};
String b[]={"18","Jupiter","racecar","Sporting
Event","Two","Irregular","November","TEZ","1","Millimeter","7","Stomach","Australia","Glas
s Slipper",
"1872","England","Spring","Green","Irony","Jainism","Ear","1000
words","12","10","Russia","for this","States","Algeria","Alpha","Isoceles","The Van",
"Antigua","F.R.I.E.N.D.S.","Chandler
Bing","Aries","Rapunzel","Mowgli","Justin Timberlake","Casino Royale","Mathew
McCaughney","Pinocchio",
"100","3","Smell","24","Marco
Matterazi","15","Ronaldinho","Cricket","113"};
String c[]={"22","Saturn","train","Sea
Creature","One","Repetitive","January","OWO","3","Yard","8","Head","Europe","Ring","1867"
,"Brazil","Summer",
Android Quiz Contest App Code_6

End of preview

Want to access all the pages? Upload your documents or become a member.