Java Android开发:实现MCQ问答应用程序

Java Android开发:实现MCQ问答应用程序,java,android,arrays,database,sqlite,Java,Android,Arrays,Database,Sqlite,我是android应用程序开发的初学者,当时正在尝试构建一个简单的MCQ问答应用程序 我所做的是制作一个二维数组,并将问题、可能的答案和正确的答案存储在其中 此图中可以看到表中的示例: 所以我给我的数组数据库命名。创建此名为数据库[][]的数组的代码如下: database = new String[][]{ {"Before marking the finishing line on a running track, a groundsman measures

我是android应用程序开发的初学者,当时正在尝试构建一个简单的MCQ问答应用程序

我所做的是制作一个二维数组,并将问题、可能的答案和正确的答案存储在其中

此图中可以看到表中的示例:

所以我给我的数组数据库命名。创建此名为数据库[][]的数组的代码如下:

    database = new String[][]{
            {"Before marking the finishing line on a running track, a groundsman measures out its 100 m length. Which instrument is the most appropriate for this purpose?",
                    "measuring tape","metre rule","30 cm ruler","micrometer", "A"},
            {"A car of mass 1500 kg travels along a horizontal road. It accelerates steadily from 10 m / s to 25 m / s in 5.0 s. What is the force needed to produce this acceleration?",
                    "300N","500N","4500N","D.7500N", "C"},
            {"A lorry of mass 10 000 kg takes 5000 kg of sand to the top of a hill 50 m high, unloads the sand and then returns to the bottom of the hill. The gravitational field strength is 10 N / kg. What is the overall gain in potential energy?",
                    "250 000 J","750 000 J","2 500 000 J","D.7 500 000J", "C"},     
            {"A liquid-in-glass thermometer contains mercury. Which physical property of the mercury varies with temperature, enabling the thermometer to operate?",
                        "mass","melting point","resistance","volume", "D"}, 
            {"Thermal energy of 12 000 J is supplied to a 2.0 kg mass of copper. The specific heat capacity of copper is 400 J / (kg °C). What is the rise in temperature?",
                        "15 Degree C","30 Degree C","60 Degree C","100 Degree C", "A"}, 
    };
因此,每一行基本上都是一个新问题,有自己的一套可能的答案

至于界面,有一个文本视图显示问题。有四个按钮显示每个答案。你点击一个按钮来回答。接下来是下一个问题

    textviewQuestion.setText(database[x][y]);
    buttonA.setText("A. " + database[x][1]);
    buttonB.setText("B. " + database[x][2]);
    buttonC.setText("C. " + database[x][3]);
    buttonD.setText("D. " + database[x][4]);


现在我的问题是,如果我想让这个应用程序更加通用,那么使用其他方法来实现这些问题是否更好?我是说也许我可以把问题储存在文本文件里?还是应该使用SQLite?我不知道优点和缺点以及基本上的限制是什么?

我有pdf格式的问题,所以我可以用它将这些问题直接从pdf链接到应用程序吗?


我还希望能够提出包括一些图片在内的问题。如何做到这一点?请帮我指出一些好的资源。非常感谢

以下代码有助于在应用程序中打开pdf

File pdfFile = new File(path); 
        if(pdfFile.exists()) 
        {

            Uri path = Uri.fromFile(pdfFile); 
            Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
            pdfIntent.setDataAndType(path, "application/pdf");
            pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            try
            {
                startActivity(pdfIntent);
            }
            catch(ActivityNotFoundException e)
            {
                Toast.makeText(uractivity.this, "File does not exist", Toast.LENGTH_LONG).show(); 
            }
        }

谢谢!关于如何使用数据库有什么想法吗?