-3
我正在試着學習Phone.i上的數據庫。在genymotion中運行程序並且它沒有錯誤地工作但它沒有在手機上創建數據庫。您認爲什麼人?請幫幫我 。數據庫不會在手機中創建(Android)
這是DatabaseOpenHelper:
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DataOpenHelper extends SQLiteOpenHelper{
public static final String dbname = "dbtest" ;
public static final String tblname = "usertable" ;
public static final String cname = "name" ;
public static final String cid = "id" ;
public static final String cuser = "user" ;
public static final String cpass = "pass" ;
public static final String createtbl = "CREATE TABLE "+tblname+"("+cid+" INTEGER PRIMARY KEY AUTOINCREMENT,"+cname+" TEXT,"+cuser+" TEXT,"+cpass+" TEXT);" ;
public DataOpenHelper(Context context) {
super(context, dbname, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(createtbl);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXIST"+tblname);
onCreate(db);
}
,這是主要的:
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
private DataOpenHelper doh;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
doh = new DataOpenHelper(this);
doh.getWritableDatabase();
}
}
您對數據庫沒有創建什麼證據? – laalto
genymotion我去根/數據,它是空的@laalto –
設備上的私人數據文件夾,是私人的,你不能沒有根看到他們。 – laalto