On the current app I'm working on, we download some quite large JSON files from which we create a Couchbase DB. These files are some tens of megabytes. Initially, we downloaded them on the JS side and just sent those via the bridge to our custom Couchbase module. This works fine on iOS, but Android devices generally have more strict heap size limitations, and even downloading and parsing a 40 MB file will crash the app on a two-year-old device.
In Android, we have to download the files in the native code and write the DB inserts directly from the input stream. We don't have to strongly type the incoming JSON objects, so I came up with this handy snippet for creating a generic Map<String, Object> from a JSON object using plain old Android utility libraries.
Comments
Post a Comment