I'm creating a app in Android where I want to specify data in specific formats so I later can do sorting and retrieval from the file.
I've read a bit about parsing XML files, but I don't want my file visible in the storage, rather a part of the application itself "hidden in the app".
Has anyone done this before?
//Henrik
Related
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.
I understand that the cache is data that is temporarily stored from a specific app. Opening /data/data/com.blah.blah/cache/ using a root file explorer reveals these cache files to me. I am able to open and view those that are an image, but when opening a non-image cache file - usually with a text editor - I get a bunch of Chinese looking characters... I know that basically the apps cache is only viewable by said app, but is there any way to convert file to a human readable text file?
but is there any way to convert file to a human readable text file?
Contact the developers of the app and ask them.
There are a dizzying roster of possible file formats, even among "standard" types. Any given computer program might use one of those file formats, or invent their own, or use one of those formats but encrypt the file, etc. There is no requirement that all computer files contain human-readable material. For all we know, the developers of this app are storing random numbers in these files, specifically to confuse people who try to reverse-engineer their stored data.
I was going through the docs of APK EXPANSION FILES in android and I was wondering that can we have all layout files in the patch apk and application's business logic in main apk ?
I read this Android Apps Break the 50MB Barrier too.
I tried creating this but the problem I faced was our widget names need to be in R.java file which is generated automatically..If I have layout files in patch file not in the main file then I am unable to refer then using R.id.xxx.
So Please tell me if this is possible or not ?
If this is possible then how it can be achieved ?
I also want to know ,what are the resources or assets that can be added in the patch apk.
Speaking straight, It's not possible to separate the layout files from apk and then trying to access it using R.id.whatever
Expansion files are meant to store the assets such as media, docs, and other such static things which your application uses and the content of the expansion pack is stored on device's shared storage and is not linked with the apk file. To access the assets of the expansion file, you must code your application to read them from that device's shared storage location.
Coming back to the question of storing the layout files in an expansion file. To achieve this, you will have to write your own layout parser with the basic functionality similar to LayoutInflator. You can not use LayoutInflator to parse any layout file which is not part of the apk or stored on any external storage. So the idea is to store your layout files in the expansion file (which will be out of apk, on device shared storage), parse the file using your own parser, and add the views to the main layout at runtime. Though you wont be able to access your views using R.id.whatever but you can always use visual tree to access the views or while parsing the views store the referenced objects to access them for later use.
Hope this gives you a starting point.
Consider an app with a set of data files (could be music or pictures or locations or indeed anything at all) embedded in the apk.
I now want to provide to the user additional data files , either to replace or add to the original data files - the user should be able to select which files to download and not have to reinstall the whole app.
So the question is it possible to do this non-programmatically - like by providing extra apk files for the app but which only contain single data files?
This is a good use case. A simple idea could be, ask the user to check for updates, you download a XML file which defines your updates. Parse this XML file and show what the user needs to download. Then you download and save it to desired locations. Always version the XML file so that you know if updates are avialble or not!
Hi fellow android developers!
I am developing an application where I have XML files that contain my data. When doing edits in these data, I save the data to the XML files, thus these must be editable.
This I would be able to achieve using the local storage for my application with the openFileOutput method of my Context.
But how would I go around shipping my program with these datafiles already there, with some pre-filled data?
I can see the option of shipping with some XML files in my res/xml or res/raw, duplicate them to the local data storage, but then I would be unable to remove the files in my resources, and this would take up too much storage.
Please tell me what you would do in this case?
You can not include editable files with your application.
So you will have to write them to the local file system some way. Either by downloading them or including them as raw resources via openRawResource().