我創建了一個名爲「enigmeDB」數據庫和表「table_enigme」:如何在sqlite中找到我的.db文件?
public class EnigmeDatabase extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "enigmeBD";
private static final String TABLE_ENIGME = "table_enigme";
// fields
private static final String KEY_ID = "id";
private static final String KEY_DESCRIPTION = "description";
private static final String KEY_REPONSE="reponse";
private static final String KEY_CATEGORIE="categorie";
public EnigmeDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// creation of the table
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_ENIGME_TABLE =
"CREATE TABLE " + TABLE_ENIGME
+ "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ KEY_DESCRIPTION + " TEXT,"
+ KEY_REPONSE + " TEXT,"
+ KEY_CATEGORIE + "TEXT"
+ ")";
db.execSQL(CREATE_ENIGME_TABLE);
}
// Update
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ENIGME);
onCreate(db);
}....
當我打開我的DDMS透視圖,打開文件瀏覽器:/data/data/com.android.enigme(我的包)我發現「enigmeDB」,但我沒有找到「table_enigme」。
雖然在SQLite數據庫瀏覽器我的表看起來空:
我從活動中插入數據,這裏是我的課:
公共類EnigmeActivity延伸活動{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//recuperation des champs depuis main.xml
final EditText description=(EditText) this.findViewById(R.id.description);
final EditText reponse=(EditText)this.findViewById(R.id.reponse);
final EditText categorie=(EditText)this.findViewById(R.id.categorie);
Button ajouter = (Button)this.findViewById(R.id.ajouter);
final EnigmeDatabase db=new EnigmeDatabase(this);
ajouter.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.d("Etape : " , "Recuperation");
Log.i("description : ", description.getText().toString());
Log.i("reponse : ", reponse.getText().toString());
Log.i("categorie : ", categorie.getText().toString());
//add a new Enigme
Log.d("Etape : ","Insertion");
db.ajouterEnigme(new EnigmeBean(description.getText().toString(),reponse.getText().toString(),categorie.getText().toString()));
Toast.makeText(EnigmeActivity.this, "Ajout avec succes!", Toast.LENGTH_SHORT).show();
}
});
}
您是否以編程方式將數據插入到sqlite數據庫?如果是的話發佈你的代碼。 – 2012-07-14 13:06:18
是的我在表單中插入數據,並在類Activity中獲取值,然後將所有值插入到我的table_enigme中 – Angelika 2012-07-14 13:12:44
進行此更改** KEY_CATEGORIE +「TEXT」**在您的文件資源管理器中有表:/ data/data/com.android.enigme ?? – 2012-07-17 12:14:33