Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中查看完整的数据库?_Android_Database - Fatal编程技术网

如何在android中查看完整的数据库?

如何在android中查看完整的数据库?,android,database,Android,Database,如何查看我在android中创建的完整数据库。 数据库的程序如下所示- public class DatabaseHelper extends SQLiteOpenHelper { public static final String TABLE_NAME = "scorecard"; public static final String COLUMN_1 ="hole_score1"; public static final String COLUMN_2 ="hole_score2";

如何查看我在android中创建的完整数据库。 数据库的程序如下所示-

public class DatabaseHelper extends SQLiteOpenHelper 
{

public static final String TABLE_NAME = "scorecard";
public static final String COLUMN_1 ="hole_score1";
public static final String COLUMN_2 ="hole_score2";
public static final String COLUMN_3 ="hole_score3";
public static final String COLUMN_4 ="hole_score4";
public static final String COLUMN_5 ="hole_score5";
public static final String COLUMN_6 ="hole_score6";
public static final String COLUMN_7 ="hole_score7";
public static final String COLUMN_8 ="hole_score8";
public static final String COLUMN_9 ="hole_score9";
public static final String COLUMN_10 ="hole_score10";
public static final String COLUMN_11 ="hole_score11";
public static final String COLUMN_12 ="hole_score12";
public static final String COLUMN_13 ="hole_score13";
public static final String COLUMN_14 ="hole_score14";
public static final String COLUMN_15 ="hole_score15";
public static final String COLUMN_16 ="hole_score16";
public static final String COLUMN_17 ="hole_score17";
public static final String COLUMN_18 ="hole_score18";

public static final String DATABASE_NAME = "scorecard.db";
public static final int DATABASE_VERSION = 1;
//create database
public static final String DATABASE_CREATE = "create table " + TABLE_NAME + " ( " + BaseColumns._ID + " integer primary key autoincrement, " + COLUMN_1 + " integer, " + COLUMN_2  + " integer, " + COLUMN_3 +" integer, "+ COLUMN_4 +" integer, "+ COLUMN_5 +" integer, "+ COLUMN_6 +" integer, "+ COLUMN_7 +" integer, "+ COLUMN_8 + " integer, "+COLUMN_9 +" integer, "+ COLUMN_10 +" integer, "+ COLUMN_11 +" integer, "+ COLUMN_12 +" integer, "+ COLUMN_13 +" integer, "+ COLUMN_14 +" integer, "+ COLUMN_15 +" integer, "+ COLUMN_16 +" integer, "+ COLUMN_17 +" integer, "+ COLUMN_18 +  " integer);";

public DatabaseHelper(Context context) 
{
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) 
{
    // TODO Auto-generated method stub
    Log.v("nikhil","Creating a database");
    db.execSQL(DATABASE_CREATE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
{
    // TODO Auto-generated method stub
    Log.w(DatabaseHelper.class.getName(),
            "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
}


}
要查看当前的数据库,这是我的代码,但只显示数据库中的一个字段

public class statistics extends Activity {

private DatabaseHelper dataHelper;

SQLiteDatabase db;

String columns[] = {"hole_score1" ,"hole_score2" ,"hole_score3" ,"hole_score4" ,"hole_score5" ,"hole_score6" ,"hole_score7" ,"hole_score8" ,"hole_score9" ,"hole_score10" ,"hole_score11" ,"hole_score12" ,"hole_score13" ,"hole_score14" ,"hole_score15" ,"hole_score16" ,"hole_score17" , "hole_score18"};


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.statistics);
    TextView tv;
    tv = (TextView)this.findViewById(R.id.textView1);

    dataHelper = new DatabaseHelper(this);
    db = dataHelper.getReadableDatabase();
    String data = data();
    tv.setText(data);
}

public String data(){
    Cursor c;
    String result;


     c = db.query("scorecard",columns,null,null,null,null,null);


               if (c.moveToFirst()){ 
                    for(int i=0;i<18;i++){
                    result = c.getString(i);
                    return result;
                }
               }




 }
}

切换到DDMS模式,然后进入data/data/your package name,然后进入database文件夹。将数据库从其文件夹中拉出并粘贴到任意文件夹。然后可以使用sqlite浏览器查看数据库


您可以在Eclipse中查看表结构和数据。以下是步骤

为Eclipse安装SQLItemManagerPlugin。如果你已经有了,跳到第5步。 从这里下载*.jar文件 将*.jar文件放入eclipse/dropins文件夹/ 重新启动eclipse 在eclipse的右上角,单击DDMS图标 在左侧面板中选择适当的仿真器 在主面板上的文件资源管理器选项卡中,转到/data/data/[YOUR.APP.NAMESPACE]/databases 在DDMS图标下面,当您选择数据库时,应该会有一个新的数据库蓝色图标亮起。单击它,您将看到一个Questoid Sqlite管理器选项卡打开以查看您的数据。 *注意:如果数据库没有亮起,可能是因为您的数据库没有*.db文件扩展名。确保您的数据库名为[database\u NAME].db

*注意:如果要使用不带.DB扩展名的DB:

下载此Questoid SqLiteBrowser:

解压并将其放入eclipse/dropins而不是插件中


查看此项了解更多信息

您到底想要什么?你是要显示Sqlite表数据还是谈论Sqlite数据库视图工具?