AFAIKT you are attempting to determine the "size" of one row by the difference in the file size. This must fail, because SQLite allocates and writes the database file in units of "database pages".
Does your definition of "size" include the index entries pertaining to a row? Does it include the overhead of storing it in a b* tree? Does it include the overhead of storing blob data ? The net size of a row (that does not contain large string and/or blob fields and excluding all overhead) is about 1 (the size of the header length varint) + n (one one-byte varint per field) + sum of the size of the varints for integer fields with an actual value other than NULL, 0 or 1 + sum of the lengths of the actuial values of string/blob fields longer string/blob values may add one or more bytes to the corresponding per-field varint, enough of those may add one or more bytes to the header length varint So a record of 20 fields of all NULL/0/1 takes up at least 21 bytes (in INTEGER PRIMAY KEY or WITHOUT ROWID tables and a rowid of 0 or 1) NET but may use up to 201 bytes NET if all the fields contain sufficiently large integers. -----Urspr?ngliche Nachricht----- Von: m.g.001 [mailto:m.g.001 at web.de] Gesendet: Dienstag, 30. Juni 2015 14:44 An: sqlite-users at mailinglists.sqlite.org Betreff: [sqlite] Question about getting size of stored data Hello, I am new to this mailinglist. I think I have to send my question here. My Name is Michael and I come from Germany. At the moment I develope a few android apps for my study. Is it possbile to get the size of one stored row inside my sqlite database? I tried the following, but it returns different sizes every time. But my test data is the same so I think it should have the same size. public long getObjectSize(MyData data) { if(getSize() == 0) //because i don't want to divide by zero { insertOneFakeData(data); } long vorvorherdatasize = getDataSize(); long checkdatasize; do //this is for writing till the end of the current block size { insertOneFakeData(data); checkdatasize = getDataSize(); }while(checkdatasize == vorvorherdatasize); //dataSize changed, so size-1 should be the number ob rows stored in the old size. long vorhersize = getSize()-1; //number of elements before next write long vorherdatasize = getDataSize(); //Size of the file before next write do { insertOneFakeData(data); checkdatasize = getDataSize(); }while(checkdatasize == vorherdatasize); long nachherdatasize = checkdatasize; long nachhersize = getSize()-1; //number of rows before new block was reserved long size = nachhersize - vorhersize; //number of elements in the last block long datasize = vorherdatasize - vorvorherdatasize; //datasize oft he last block long objectSize = datasize / size; //my try to get the size of 1 row return objectSize; } Only for completeness my other used methods: public long getDataSize() //returns size of file in which my database is stored { SQLiteDatabase db = this.getWritableDatabase(); db.getPath(); long size = new File(db.getPath()).length(); return size; } public long getSize() //returns number of rows in my database { Log.i("ESmartDataManager","getSize"); SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery("SELECT " + _ID + ", " + CANID + ", " + RTR +", " + IDE + ", " + DLC + ", " + TIMESTAMP + ", " + DATA + " FROM " + FAKETABLE_NAME , null); return cursor.getCount(); } Can you help me to get the size of 1 row? Is it possible? _______________________________________________ sqlite-users mailing list sqlite-users at mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: hick at scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.