Java 如何检查表是否已创建,以及如何使用SQlite从radiobutton和微调器获取值?

Java 如何检查表是否已创建,以及如何使用SQlite从radiobutton和微调器获取值?,java,android,sqlite,android-sqlite,sqliteopenhelper,Java,Android,Sqlite,Android Sqlite,Sqliteopenhelper,我正在开发一个android应用程序,其中有登录活动和问卷活动,问卷活动包含问题,这些问题作为单选按钮和按钮(下一步)。因此,现在我想创建一个数据库来存储各个字段的值。我已经输入了dataHandler和Login.java的代码,现在的问题是我想知道表是否已经创建,以及如何查看我的表。请帮助我,并检查我的代码是否正确。 提前谢谢 下面是DatabaseAdapter.java的代码 public class DatabaseAdapter { DatabaseHandler dbhand

我正在开发一个android应用程序,其中有登录活动和问卷活动,问卷活动包含问题,这些问题作为单选按钮和按钮(下一步)。因此,现在我想创建一个数据库来存储各个字段的值。我已经输入了dataHandler和Login.java的代码,现在的问题是我想知道表是否已经创建,以及如何查看我的表。请帮助我,并检查我的代码是否正确。 提前谢谢

下面是DatabaseAdapter.java的代码

public class DatabaseAdapter  {
 DatabaseHandler dbhandler;

 public DatabaseAdapter(Context context){
     dbhandler =new DatabaseHandler(context);

 }
public long insertData(String name,String desig,String years,String dept)
  {
    SQLiteDatabase db=dbhandler.getWritableDatabase();
     ContentValues content=new ContentValues();
     content.put(DatabaseHandler.NAME, name);
     content.put(DatabaseHandler.DESIGNATION,desig);
     content.put(DatabaseHandler.YEARS, years);
     content.put(DatabaseHandler.DEPARTMENT, dept);
     long  id=db.insertOrThrow(DatabaseHandler.TABLE_NAME, null, content);
     return id;
  }

static class DatabaseHandler extends SQLiteOpenHelper {
  private static final String NAME="name";
  private static final String DESIGNATION="desig";
  private static final String YEARS="years";
  private static final String DEPARTMENT="dept";
  private static final String TABLE_NAME="visteon";
  private static final String DATA_BASE_NAME="VisteonSurvey";
  private static final  int DATABASE_VERSION=2;
  private static final String CREATE_TABLE="CREATE TABLE "+TABLE_NAME+"("+NAME+" VARCHAR(255),"+DESIGNATION+"text not null,"+YEARS+" text not null,"+DEPARTMENT+" text not null);";

 public DatabaseHandler(Context context)
 {
    super(context,DATA_BASE_NAME,null,DATABASE_VERSION);

 }
   @Override
    public void onCreate(SQLiteDatabase db) {

        try{
             db.execSQL(CREATE_TABLE);
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
         try {
            db.execSQL("DROP TABLE IF EXISTS visteon");
             onCreate(db);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
下面是Login.java的代码

public void OnClickListener(View v)
{
  name=(EditText)findViewById(R.id.editText1);
  years1=(RadioButton)findViewById(R.id.radioButton3);
  years2=(RadioButton)findViewById(R.id.radioButton4);
  years3=(RadioButton)findViewById(R.id.radioButton5);
  manager=(RadioButton)findViewById(R.id.radioButton1);
  teamleader=(RadioButton)findViewById(R.id.radioButton2);
  rg1=(RadioGroup)findViewById(R.id.Designation);
  rg2=(RadioGroup)findViewById(R.id.Years);
  dept=(Spinner)findViewById(R.id.spinner1);
  proceed = (Button)findViewById(R.id.button1);
  proceed.setOnClickListener(new View.OnClickListener()
  {
        @Override   
        public void onClick(View v) 
        {
            if (validationSuccess()) 
            {
                if(manager.isChecked())
                {
                    Intent managerIntent = new Intent(getApplicationContext(), ManagerQuestionnaire1.class); // <----- START "SEARCH" ACTIVITY
                    startActivityForResult(managerIntent, 0);
                }
                else 
                      {
                      Intent teamleaderIntent = new Intent(getApplicationContext(), TeamleaderQuestionnaire1.class); // <----- START "TYPE ENTRIES OUT" ACTIVITY
                      startActivityForResult(teamleaderIntent, 0);
                }

            }   
            else {
              AlertDialog();
               }
            String user=name.getText().toString();
            String designation=rg1.getContext().toString();
            String experience=rg2.getContext().toString();
            String department=dept.getContext().toString();

            long id= DatabaseHandler.insertData (user, designation, experience, department);
            Toast.makeText(getBaseContext(),"Form Updated",Toast.LENGTH_LONG).show();

         }
  });
public void OnClickListener(视图v)
{
name=(EditText)findViewById(R.id.editText1);
年份1=(RadioButton)findViewById(R.id.radioButton3);
年份2=(RadioButton)findViewById(R.id.radioButton4);
年份3=(RadioButton)findViewById(R.id.radioButton5);
manager=(RadioButton)findViewById(R.id.radioButton1);
组长=(RadioButton)findViewById(R.id.radioButton2);
rg1=(放射组)findViewById(R.id.名称);
rg2=(放射组)发现的视野视野(R.id.Years);
dept=(喷丝器)findViewById(R.id.spinner1);
继续=(按钮)findViewById(R.id.button1);
继续.setOnClickListener(新视图.OnClickListener()
{
@凌驾
公共void onClick(视图v)
{
if(validationSuccess())
{
if(manager.isChecked())
{

Intent managerIntent=newintent(getApplicationContext(),ManagerQuestionnaire1.class);//如果您在emulator上运行代码,则可以从路径data/data/your app name/database/复制数据库。您还可以在其中看到创建的表和值。您应该使用Sqlite数据库浏览器来查看数据库database@jyomin你能给我提供下载SQlite数据库浏览器的链接吗?@Umang我还检查了文件浏览器data/data/但我找不到我的应用程序和数据库。@jyomin你能检查一下我的代码是否正确,我是否正确获得了radiobutton和spinner的值。