In my project My create table query executed successfully when i debug with break points.. but when i saw in File explorer->mnt->sdcard->android->Mydbname->mydbname.db no tables are created there.. I also checked in data->data->package name->.... I created db using sqlite admin.
// Database name definitions
public static final String DATABASE_NAME = "MMPDB.db";
// Table name definitions
public static final String LOG_IN_TABLE = "LogIn";
public static final String FI_GOODS_DETAIL_TABLE = "fiGoodDetail";
public static final String FI_GOODS_SUMMARY_TABLE = "fiGoodSummary";
public static final String ITEM_DETAIL_TABLE = "itemDetail";
public static final String SETTINGS_TABLE = "Setting";
// LogIn table fields declaration
public static final String LOGIN_USERNAME = "userName";
public static final String LOGIN_PASSWORD = "password";
// fiGoodDetail table fields declaration
public static final String FIGOODSDETAIL_FINISHGOODS = "fiGoods";
public static final String FIGOODSDETAIL_ITEMDESC = "itemDesc";
public static final String FIGOODSDETAIL_FINISHQTY = "fiQty";
public static final String FIGOODSDETAIL_FINISHUNITWEIGHT = "fiUnitWeight";
public static final String FIGOODSDETAIL_FINISHTOTALWEIGHT = "fiTotalWeight";
public static final String FIGOODSDETAIL_LOTBINNUM = "lotBinNum";
// fiGoodSummary table fields declaration
public static final String FIGOODSSUMMARY_FINISHGOODS = "fiGoods";
public static final String FIGOODSSUMMARY_FINISHQTY = "fiQty";
public static final String FIGOODSSUMMARY_FINISHUNITWEIGHT = "fiUnitWeight";
public static final String FIGOODSSUMMARY_FINISHTOTALWEIGHT = "fiTotalWeight";
public static final String FIGOODSSUMMARY_ITEMDESC = "itemDesc";
public static final String FIGOODSSUMMARY_QTYUM = "qtyUm";
public static final String FIGOODSSUMMARY_QTY = "qty";
public static final String FIGOODSSUMMARY_YIELD = "yield";
// itemDesc table fields declaration
public static final String ITEMDETAIL_FINISHGOODS = "fiGoods";
public static final String ITEMDETAIL_ITEMDESC = "itemDesc";
public static final String ITEMDETAIL_LOCTID = "loctId";
public static final String ITEMDETAIL_LOTBINNUM = "lotBinNum";
public static final String ITEMDETAIL_QTYUM = "qtyUm";
public static final String ITEMDETAIL_QTYUMUSED = "qtyUmUsed";
public static final String ITEMDETAIL_YIELD = "yield";
public static final String ITEMDETAIL_ACTUALQTY = "actQty";
public static final String ITEMDETAIL_ACTUALSCARP = "actScrp";
public static final String ITEMDETAIL_UNITCOST = "unitCost";
public static final String ITEMDETAIL_TOTALCOST = "totalCost";
// Setting table fields declaration
public static final String SETTINGS_SERVERPATH = "serverPath";
// public static final String SETTINGS_COMPANY="company";
// Creation of Query for Each Table.
// tlogin table creation query
public static final String LOG_IN_TABLE_CREATE_QUERY = "CREATE TABLE "
+ LOG_IN_TABLE + "(" + LOGIN_USERNAME + " TEXT,"
+ LOGIN_PASSWORD + " TEXT);";
// tfigodet table creation query
public static final String FI_GOODS_DETAIL_TABLE_CREATE_QUERY = "CREATE TABLE "
+ FI_GOODS_DETAIL_TABLE + "(" + FIGOODSDETAIL_FINISHGOODS + " TEXT,"
+ FIGOODSDETAIL_ITEMDESC + " TEXT,"
+ FIGOODSDETAIL_FINISHQTY + " TEXT,"
+ FIGOODSDETAIL_FINISHUNITWEIGHT + " TEXT,"
+ FIGOODSDETAIL_FINISHTOTALWEIGHT + " TEXT,"
+ FIGOODSDETAIL_LOTBINNUM + " TEXT);";
// tfigosum table creation query
public static final String FI_GOODS_SUMMARY_TABLE_CREATE_QUERY = "CREATE TABLE "
+ FI_GOODS_SUMMARY_TABLE
+ "("
+ FIGOODSSUMMARY_FINISHGOODS
+ " TEXT,"
+ FIGOODSSUMMARY_FINISHQTY
+ " TEXT,"
+ FIGOODSSUMMARY_FINISHUNITWEIGHT
+ " TEXT,"
+ FIGOODSSUMMARY_FINISHTOTALWEIGHT
+ " TEXT,"
+ FIGOODSSUMMARY_ITEMDESC
+ " TEXT,"
+ FIGOODSSUMMARY_QTYUM
+ " TEXT,"
+ FIGOODSSUMMARY_QTY
+ " TEXT,"
+ FIGOODSSUMMARY_YIELD
+ " TEXT);";
// titemdet table creation query
public static final String ITEM_DETAIL_TABLE_CREATE_QUERY = "CREATE TABLE "
+ ITEM_DETAIL_TABLE + "(" + ITEMDETAIL_FINISHGOODS + " TEXT,"
+ ITEMDETAIL_ITEMDESC + " TEXT," + ITEMDETAIL_LOCTID + " TEXT,"
+ ITEMDETAIL_LOTBINNUM + " TEXT," + ITEMDETAIL_QTYUM + " TEXT,"
+ ITEMDETAIL_YIELD + " TEXT," + ITEMDETAIL_ACTUALQTY + " TEXT,"
+ ITEMDETAIL_QTYUMUSED + " TEXT," + ITEMDETAIL_ACTUALSCARP + " TEXT,"
+ ITEMDETAIL_UNITCOST + " TEXT," + ITEMDETAIL_TOTALCOST + " TEXT);";
// tsettings table creation query
public static final String SETTINGS_TABLE_CREATE_QUERY = "CREATE TABLE "
+ SETTINGS_TABLE + "(" + SETTINGS_SERVERPATH + " TEXT);";
// Constructor to create Database
public MmpDBHelper(Context context) {
DATABASE_FILE_PATH = new File(Supporter.getAppCommonPath(),
DATABASE_NAME);
if (!DATABASE_FILE_PATH.exists()) {
try {
db = SQLiteDatabase.openOrCreateDatabase(DATABASE_FILE_PATH,
null);
// openDatabase();
db.beginTransaction();
db.execSQL(LOG_IN_TABLE_CREATE_QUERY);
db.execSQL(FI_GOODS_DETAIL_TABLE_CREATE_QUERY);
db.execSQL(FI_GOODS_SUMMARY_TABLE_CREATE_QUERY);
db.execSQL(ITEM_DETAIL_TABLE_CREATE_QUERY);
db.execSQL(SETTINGS_TABLE_CREATE_QUERY);
db.setTransactionSuccessful();
Log.i("Success", "All tables created successfully");
} catch (Exception e) {
db.endTransaction();
errCode = "Error 501";
msg = "Table creation failed";
errMsg = errCode + " : " + msg;
LogFileCreator.appendLog(errMsg);
} finally {
// db.endTransaction();
db.close();
}
}
}
Aucun commentaire:
Enregistrer un commentaire