I'm writing an Android application that consists in a collection of university notes taken in markdown.
I would like to save these notes into an sqlite database, in such a way that, when I will write new notes or modify old ones, I'd need simply to upload the new files in the database and update the db version in the app.
I'm able to add a table in my database whose tuples contain the plain markdown I wrote.
Though, I would like to be able to load in the database the "image" folder in which I have put the images I refer to in the markdown files.
----------------------------------------------------- EDIT 1 ---------------------------------------------------------------
In case I've not been clear, let me give you some context:
I have a folder in my PC in which I've put many markdown files.
In the same folder I've created a folder called "imgs", and whenever I want to add an image in any of the markdown files I write something like this within the markdown file:
<img src="imgs/image_name.jpg">.
Let me show you what it looks like:
the folder where I've put all my markdown files and the image folder
So, suppose I've just downloaded the picture of a cat and called such picture cat.jpg.
Suppose I want to add this picture in the markdown file called 1_introduction.md.
I would simply put the image in the folder imgs and write in 1_introduction.md the following:<img src="imgs/cat.jpg">
What I've explained above is simply what I've always done on my PC for the last couple of years: I wrote plain markdown files and saved images into a folder (as probably 99% of people do when dealing with markdown files!)
NOW I want to store these markdown files (and obviously the imgs folder as well) into the database of an Android application.
MOREOVER I want to be able to modify the content of these markdown files (locally, in my PC. I don't want users to be able to modify these files) and give the possibility to the users of the Android app to retrieve the updated content simply by updating the app (NOT reinstalling it).
my final questions are:
is there any approach suggested by the Android community to handle this scenario? In case, what is it?
In case there is not, is it possible to save the imgs folder in the database, along with the markdown files? and, if it's possible, how should I modify the html tags <img src="imgs/image_name.jpg"> in order for it to work?
The other alternative would be to save the folder that contains both the markdown files and the imgs folder in the folder assets, but wouldn't the user need to redownload the app in order to witness the changes I'd make?
Thank you in advance!
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 want to make an app which can print bill invoices. I had made a basic layout in xlsx(excel) format leaving the places(cells) for inputting data according to different bills. For that I had put that xlsx file in raw folder and with help of apache poi library, I can easily read the file data. But now i want to update specific cell data in same file(in raw folder) and then print that with help of my app i.e. So that there will be no need to open excel file at all, just fill the information in edittext and press button to print bill. Is there a way to do so? I have browsed through lot of existing stackoverflow threads but none of them are helpful.
i want to save HTML pages on my android projects. since assets folder is read only,
i can not save them there, because i can not edit them if someday i need to, so where is the best place to save it?
Put your files inside the asset folder and copy them to the SD card the first time the application is started.
In this way you'll be able to edit those files if needed.
Helpful links:
How to copy files from assets to SD card
Intercept the first time the app is started
I have created an android app that calculates the numerical values of word, and gives you a list of other words with the same numerical value. The way I have been doing it, is storring the words and value in a .properties file. Ie. A line from a .proprties file called "myWords" will have something like: 61=you, then I just use a get() method to call it,
ie. String myString = ResourseBundle.get("myWords").get("61"); would return the string "you". Is there a better way to do this? My guess is that this is not the proper use of a .properties file, and I was wondering if there was another way to do this correctly. I want to include the file in assets folder of the app, and from my limited understanding of sqlite, you can create a file within android, but you can't just include a file in the assets folder, and then read it. So that said, is there some other type of file that I should use, or was I wrong about sqlite, or is the .properties file being used correctly?
SQLite is your best bet and is the best way to handle your data on an Android phone, that is why Google bundled it on Android in the first place, to avoid people the pain of dealing with files.
If you follow this Tutorial they will show you how to create your database in your computer and then load it up on your "assets" folder and access it from your Android application.
Hope that helps!
You can use a csv file, read it from the assets folder each time the app starts or only once after installation and then store the values in a database.
Take a look at my answer here on how to read the files included in your app (you would use a csv file instead of a libray, but it's still reading files): Hosting an executable within Android application
Edit: here's another example to read from the assets folder: Image uploaded from the android app space seems corrupted
You can try out database option. Here is an interesting tutorial on how to pre-populate a database and then ship it out in the APK.
I have a really big .txt file ( 4.2MB) that I have to access in my android application. It consists of words and their definitions in this format:
word - definition
word2 - definition2
Should I put this file in /assets folder or in res/raw? Or something third? Maybe I should put it on SD card because of its size?
And how should I get file contents in the code?
I have tried both assets and res/raw, but the file size always seems to be the problem or I am doing something wrong.
A SQLLite database could be used for this.
An example of this can be found in the latest android SDK. http://developer.android.com/resources/samples/SearchableDictionary/index.html
Putting it in raw folder would be a better idea according to me.
since putting in the SDCard would make it available to user also, and the user might screw up your database.