我将数据库文件下载到Android存储。我很困惑为什么打开数据库后查询文件大小不同。下载后,它返回“大小”。打开后,它返回“磁盘大小”。
//download database file to storage
...(the content length from server is 52224)
//query size
databaseFile = new File(DBGlassConfig.getDatabasePath());
long sizeBeforeLoading = databaseFile.length(); // 52224
//open database
if (databaseHandler == null)
databaseHandler = new DatabaseHandler(MainActivity.this);
//query size
databaseFile = new File(DBGlassConfig.getDatabasePath());
long sizeAfterLoading = databaseFile.length(); // 53248
//open database
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
db =
SQLiteDatabase.openOrCreateDatabase(DBGlassConfig.getDatabasePath(), null);
}