无法在文件资源管理器中的DDMS模式下查看SqlLite Db

时间:2015-07-02 11:08:02

标签: android android-sqlite

我遵循了一些示例,尝试在SQLLite中的一个数据库中创建多个表。但我无法在我的模拟器中看到DDMS模式下的数据库。 我为登录创建了两个Database One,为整个应用程序创建了一个。登录Db在Eclipse的DDMS视图内的文件资源管理器选项卡中可见。我认为我的DBHelper类存在一些问题。 如果你能查看它并让我知道这个问题

我在这样的页面上初始化它

Inititate

DBHelper helper;

final Context context = this;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.studentsignup)

    //Initiate DB
    helper = new DBHelper(context);

代码

        package com.demo.assesmenttool;

    /***
     *    Application Name : DemoProject
     *    Author : Tushar Narang
     *    Website : ------
     */


    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;

    public class DBHelper extends SQLiteOpenHelper {

        // Static Final Variable database meta information

        static final String DATABASE = "AssesmentTool.db";
        static final int VERSION = 1;

        //Table Student Details
        static final String TABLEStudent = "StudentDetails";
        static final String S_ID = "_id";
        static final String SchoolID = "schoolid";
        static final String SchoolName = "schoolname";
        static final String StudentFirstName = "StudentFirstName";
        static final String StudentLastName ="StudentLastName";
        static final String StudentClassLevel ="StudentClassLevel";
        static final String RollNo="RollNo";
        static final String TestDate ="TestDate";

         //Table Response Details   
        static final String TABLEResponse = "TableResponse";
        static final String R_ID = "_id";
        static final String StudentID = "StudentID";
        static final String R_QuestionID = "QuestionID";
        static final String QuestOptionID = "QuestOptionID";

        //Table Question Master
        static final String TableQuestionMaster = "questionmaster";
        static final String Q_ID= "_id";
        static final String Title = "Title";
        static final String TitleDescription = "TitleDescription";
        static final String QuestionText = "QuestionText";
        static final String QuestionImage = "QuestionImage";
        static final String QuestionTemplate = "QuestionTemplate";
        static final String CorrectOptionID = "CorrectOptionID";

        //Table Template Master
        static final String TableTemplateMaster = "TemplateMaster";
        static final String T_ID= "_id";
        static final String Name = "Name";
        static final String Description = "Description";

        //Table Question Option 
        static final String TableQuestionOption = "TableQuestionOption";
        static final String TQP_ID= "_id";
        static final String TQP_QuestionID = "QuestionID";
        static final String OptionText = "OptionText";

        // Override constructor
        public DBHelper(Context context) {
            super(context, DATABASE, null, VERSION);

        }

        // Override onCreate method
        @Override
        public void onCreate(SQLiteDatabase db) {


            //Create Table Student Details
            db.execSQL("CREATE TABLE " + TABLEStudent + " ( " + S_ID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + SchoolID + " INTEGER, "
                    + SchoolName + " text, " + StudentFirstName + " text, "  + StudentLastName + " text, " + RollNo + " INTEGER," + TestDate + " text," + StudentClassLevel + " text)");


            //Create Table Response Details     
            db.execSQL("CREATE TABLE " + TABLEResponse + " ( " + R_ID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + StudentID + " text, "
                    + R_QuestionID + " text, " + QuestOptionID + " text)");


            //Create Table Question Master
            db.execSQL("CREATE TABLE " + TableQuestionMaster + " ( " + Q_ID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + Title + " text, "
                    + TitleDescription + " text, " + QuestionText + " text, "  + QuestionImage + " text, " + QuestionTemplate + " INTEGER," + CorrectOptionID + " INTEGER)");


            //Create Table Template Master
            db.execSQL("CREATE TABLE " + TableTemplateMaster + " ( " + T_ID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + Name + " text, "
                    + Description + " text)");


            //Create Table Question Option  
            db.execSQL("CREATE TABLE " + TableQuestionOption + " ( " + TQP_ID
                    + " INTEGER PRIMARY KEY AUTOINCREMENT, " + TQP_QuestionID + " INTEGER, "
                    + OptionText + " text)");   

        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

            // Drop old version table
            db.execSQL("Drop table " + TABLEStudent);
            db.execSQL("Drop table " + TABLEResponse);
            db.execSQL("Drop table " + TableQuestionMaster);
            db.execSQL("Drop table " + TableTemplateMaster);
            db.execSQL("Drop table " + TableQuestionOption);
            // Create New Version table
            onCreate(db);
        }

}

0 个答案:

没有答案