How to export data from layout to file - android

I am working on an android app project for work, in Android Studio, which contain texts and switch buttons. I would like to save all this data in file (PDF,excel, etc.), and then upload it to cloud.
How can I store all the data into file?
Do I have to use any Database?
I tried to use itext, and created a PDF containing only text.

If you want to export data to a pdf file, using iText (as your tag indicates) there are various options.
You can use the core API, which allows you to insert tables, lists and text. For more information you can consult
http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples
You can export to HTML, and then use pdfHTML (newest iText add-on) to convert the given HTML to pdf. For more information (+examples) consult
http://itextpdf.com/itext7/pdfhtml

Related

How to add markdown's image folder in a sqlite database?

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!

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.

Read, write and print xlsx file in raw resource folder android

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.

Use excel files in android application

I have multiple long excel files on my computer that I need to use in my android application.
The excel files contains 10 000 rows and I was wondering how I could include it in the project so I can use it in the application on the phone. I know I should use some sort of database so I can use SQLite in the android application. How can that be done? Any links to tutorials?
thank you
You can use the Java Excel library for this. First you need to parse the excel file and then store that data in your mobile database.
You can use the following URL for further clarification.
http://www.vogella.com/tutorials/JavaExcel/article.html

what kind of file should i use in android to reference information that i stored?

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.

Categories

Resources