I get this error: Data exceeds UNCOMPRESS_DATA_MAX on android 2.2 but not on 2.3

后端 未结 5 1078
借酒劲吻你
借酒劲吻你 2020-12-03 14:22

I am getting an error only on the version android 2.2 but not on 2.3.

The error :

 04-26 13:41:34.862: ERROR/Database(3701):  sqlite3_open_v2(\"/data         


        
相关标签:
5条回答
  • 2020-12-03 14:46

    Just changing the .db extension to .png it will worked in 2.2 and above devices

    0 讨论(0)
  • 2020-12-03 14:48

    I found a workaround for Froyo (2.2), but the APK got from 4.x megs long to 10.x megs. Make it simple: rezip the apk file, with compression 0. I did this on Windows: 1.-Rename the apk file to zip, 2.-unzip it to some folder, 3.-zip it again with "store" option (I'm really using WinRAR, so "store" means no compression at all), 4.-then rename it back from zip to apk, 5.-and install it.

    0 讨论(0)
  • 2020-12-03 14:50

    You can split the file and put the split files in assets folder.
    For e.g largfile.db to db1.db, db2.db, db3.db
    And then write code to combine these files back to largefile.db on the device.

    0 讨论(0)
  • 2020-12-03 15:02

    I too have a similar problem and after much searching, I found this page to answer my question.

    http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/

    In summary, Android compresses any asset file except the ones that are list on the page, since they are already compressed. This compressing is generally a good thing, but it comes back to haunt programmers when a file is too big. The two options that the author suggests are to 1)rename the database file to be one the doesn't get compressed (such as .jpg) or 2) turn off compression for the database's file extension (see the blog post on how to do that). Number 2 can be difficult though if you are using Eclipse so the author recommends using the first option.

    This whole problem was corrected in Android 2.3.3 which is why you don't have the error appear :)

    EDIT: This site explains it really simply: https://web.archive.org/web/20120423232710/http://www.nutprof.com/2010/12/data-exceeds-uncompressdatamax.html

    EDIT 2: Looking back on this answer, I realize that depending on the size of your file, perhaps you could consider downloading the file from a web server and then copying it to wherever you need it to go. In my case, I was copying a SQLLite DB to the app private storage, but since the APK is signed, I couldn't get rid of the old database from my assests. So now instead of all that funky naming stuff, I just went and had it download it from the internet on the first run and put it in the private space. That way the application doesn't double its size on first run.

    0 讨论(0)
  • 2020-12-03 15:05

    I did what Bob has mentioned above. It worked great for me. I was unable to run the app on versions older than 2.3.3 but when I renamed my .html file (which was 4MB due to Web SQL commands) to .jet (or for that matter any already-compressed extension as mentioned in enter link description here), it worked fine on 2.1 update1 and 2.2 also.

    The problem was Android versions older to 2.3.3 were trying to compress all files more than 1MB in size in the /assets/ folder. So, I renamed it to already-compressed extension so that the Android does not try to compress it again. Though I am not aware of Android programming, I think that is what is happening after reading the above and few other links online.

    0 讨论(0)
提交回复
热议问题