我找不到在其中创建数据库适配器的数据库文件和表。但我可以看到数据正在保存,但我无法在我的目录中找到我的 db 文件。但我可以保存条目并在我的屏幕上查看。这是我正在创建数据库的 DBAdapter 类。
public class DBAdapter {
private static final String DB_NAME = "clientList.db";
private static final int DB_VERSION = 1;
private static final String TABLE_CLIENT = "CLIENT";
private static final String COLUMN_CLIENT_ID = "CLIENT_ID";
private static final String COLUMN_CLIENT_NAME = "CLIENT_NAME";
private static final String query = "create table test_1 " + " (COLUMN_CLIENT_ID integer primary key, COLUMN_CLIENT_NAME text)";
private Context context;
private SQLiteDatabase sqliteDatabase;
private static DBAdapater dbAdapaterInstance;
private DBAdapater(Context context){
this.context = context;
sqliteDatabase = new DatabaseHelper(this.context,DB_NAME,null,DB_VERSION).getWritableDatabase();
}
public static DBAdapater getDbAdapaterInstance(Context context){
if(dbAdapaterInstance == null){
dbAdapaterInstance = new DBAdapater(context);
}
return dbAdapaterInstance;
}
public boolean insert(int clientId , String name ){
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_CLIENT_ID,clientId);
contentValues.put(COLUMN_CLIENT_NAME,name);
return sqliteDatabase.insert(TABLE_CLIENT,null,contentValues)>0;
}
public boolean delete(int ClientID){
return sqliteDatabase.delete(TABLE_CLIENT, COLUMN_CLIENT_ID + "=" + ClientID,null)>0;
}
public boolean modify(int ClientID , String newClient){
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_CLIENT_NAME,newClient);
return sqliteDatabase.update(TABLE_CLIENT,contentValues,COLUMN_CLIENT_ID + "=" + ClientID,null)>0;
}
慕标琳琳
相关分类