简体   繁体   中英

Most efficient way to store text and media in android development

I have an application that I want to develop. The android application is more or less like a book that will allow the users to select a chapter and it will display the whole text in that chapter and a media file for the chapter. Where do you think I can store the text and the media. Should I use json format or sqlite database or I should store both text and media in a folder and access it there. Am really confused because I still want to be able to perform some query on the text search for the text in my application.

You can use binary files, where you load the data sequencial.

Or you use zip-files, in which format many programs store data. Eg .svgz is a zipped version of .svg used by Inkscape, .odf is an open source format used by eg. OpenOffice or LibreOffice (the specification says it could be either a XML- or ZIP-structure.) You can store the text in a file, where in the text it references to other files like images in the zip, like a html-file references to other files on the server in the directory. This can be a json-file or an xml-document or a binary-serialization of an object-structure. There are many zip-libraries out there,. It is a big security risk, if you do not check in the file for references to other files outside the zip, like '../../Documents/myPasswords.txt' (when you are on Windows for example and you use the %temp% directory, this may reference to 'C:/Users/BOB/Documents/myPasswords.txt' when the directory where you unpack to is '%temp%/randomName/' ), when unpacking the data to a temporary directory and load a file (however different operating systems treat this differently, Android is more secure than Windows, but the app can crash if you do not check...).

But if you do not care about filesize and if you store the data directly within the app (and not download them from the internet), you just include it in your data-folders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM