Get infomation from Compressed XML file in Android application - android

I have a compressed(.gz) xml file on my server. I need to read that file and get the information to store in the SQLite DB
Have to access the server via HTTPS.
"https://SERVER_ADDRESS/PATH/employee.gz"
Normally when I log in to the server to the folder where these xml files are stored, it asks me for user name and password. So in code how to handle this.
I searched but didn't get the exact one I need. Great if someone Can help me in this. Thanks.

Depending on how you are reading from HTTPS, GZIPInputStream might work. http://developer.android.com/reference/java/util/zip/GZIPInputStream.html
Also, look at http://developer.android.com/reference/org/apache/http/auth/UsernamePasswordCredentials.html for accessing password protected directories with http.

Related

Encrypt sqlite file for android

We have an android application which use the sqlite database, we will save many images to the file, and then user can download the db file from android client and read the images from our app, and we want to encrypt the file to prevent the attacker get the image directly.
At first, we tried to gzip and encrypted each image before inserted to the db, then we decrypt them during the reading. However we afraid that this may cause performance problem.
Then I found this:
https://guardianproject.info/code/sqlcipher/
And it seems that sqlcipher use password to encrypt the file, then our app should have to read it by password in the client side, then if someone de-compile our apk, he can still get our password(event this password are retrieved from server) through the source file.
Is this possible? Or do I miss anything?

How to get the url of the website to which I upload a file?

Hi and thanks for any suggestion,
I have done my homework and tried to find an answer on SO and around, but so far I have been unable to find a solution.
I am trying to build some kind of FileManager to allow user to upload files on websites (any website, for example add an attachment to a mail in yahoo mail...)
Therefore my application registers a filter so that when the browser requests a file to upload the app opens up and provide the file to the requester (the web browser).
My question is:
is there a way for me to retrieve the url of the website to which the file is uploaded ?
I'm not sure I understood your question currently. my answer is relevant with the assumption: you want to have a direct download url to the file that been uploaded, and you wish to use this url in some point in the future to download that file...
I am afraid there is really no way getting such information.
there are many obstacles in the way of getting url to the file that been uploaded:
there is no any system broadcast / event that been sent in this scansion
even if the upload process was managed and initiated from you own application with you own WebView - the website you uploading to not necessarily provide you information of what is the url of the uploaded file. I know for sure that companies like yahoo not provide you this url.
if that's not enough - there is no necessarily such url at all!
the fact is that the server you uploading to is not necasserly doing anything with the uploaded file, or just not exposing him to public access with url.
from the reasons I mentioned, developing app as you which can be done only with servers providing their own API for upload files, and returns you the url as respond.
of-course each server has it own API (if at all) and you should speak with each one of the servers you'd like to support with it own language. sort of mission impossible if you want to support most of the big sites...
I had similar problem as to how can I get the URL where my file is uploaded. The answer is simple and lies in your Android code.
For uploading a file to some place, you need to know URL of the server/website.
So lets say you are uploading a file to
www.yoursite.com/appdatafolder/
For uploading to the file to the given address, you have to have a php script file sitting there, which will communicate with your android code for uploading the data.
Lets consider the address is:
www.yoursite.com/appdatafolder/upload.php
Now it depends on your code on how did you wrote your php script, in my case, I also send the name of the file to upload.php file, you can ignore it if you want or your script follows some other algo.
Lets say you want to upload importantfile.txt, so the url for uploading the file becomes
www.yoursite.com/appdatafolder/upload.php?filename="importantfile.txt"
The address you need to provide to the user in order to download the file becomes:
www.yoursite.com/appdatafolder/importantfile.txt
Now what you can do is save this address in a local database on your phone and use it whenever the user wants to download the file.
If you are afraid of securing the files which can be accessed/downloaded
www.yoursite.com/appdatafolder/
you can use htaccess. There are alot of other security mechanisms out there for securing data on the server from hacking. htaccess is simplest example.
So this is the easiest and hassel free way of solving your problem.
If you want, I can provide the php script I used.
Hope this helps.
If their is no secure layer on the web site, data sniffing by the app could be a kind of solution. you'll also probably need to deal with content encoding like gzip.
You'll need to filter the result's. It is easy to do: You just need to look at the application level in the OSI model.
Then you can apply a second filter if you know the ip address or the hostname of the concerned site.
There is even one more filter if you know the request method. But most it is get or post most of the time.
Have you looked at this question: Android file chooser? It has great example code as well as a link to a GitHub project (aFileChooser).

Attach files from file system to the application

How can I implement ability to attach files from file system to my application. Can I use some libraries, or I should do it myself programmatically? Or I can implement code of other similar application and use them?
File browser:
Link
A sample code for file browser. Or you can just let user input the location into an EditText and let app remember it.
To use external storage(like SD card), please see here
Remember the file location:
Using Shared Preferences
It is a simpler way to save persistent data than SQLite database
Send it to server:
Link
Here is an example of how to use HTTP POST to send to server

How to write the text file after received the location?

I'm implementing the application just like tracking the user's traveling.
Now I'm using the SQLite database which is record the location, time,and date
then automatically send to the MySQL server via JSON if the Internet is connecting.
But I want to do like the following:
1) I would like to keep data as a text file of each traveling before send to server.
2) I don't know that I should record data in SQLite before write as a file or not?
3) I also need to list all files in the document menu to show user all files
and check the status of all files are completely sent or did not send.
I tried to search for the good tutorial and any examples but did not find them yet.
If anyone have a good tutorial for write/read file and any idea for these, please suggests me.
Thank you so much
Here is good tutorial how to write data to file and save it to SD card.

Android log in and download csv file

I am writing an Android app and I need to download a csv file for a graph. I am not sure if I need to either put the two columns to two array strings or import them to the DB then just query. I am leaning towards just putting them to strings since the csv file will change constantly.
My two issues are:
I need to log into a specific URL to populate the CSV with the correct data such as http://myurl.net/protect/module_graph.htm?log=02. That will populate the file http://myurl.net/protect/data1.csv with the data for the correct item. Changing the log=02 to log=03 or any other number changes the content of the data1.csv file. When I pull up the first URL in a web browser it pops up a window asking for basic authentication. How do I need to call the URL to send the username and password with the request?
I need to get the CSV file downloaded and have the two columns output as strings so the graphing code can just read the data from the strings. I think I know how to download it but should I store it to the SD card and then output the data or just open the file from the web and then output the data? Also how do you tell it to put each column to an arraystring?
Any help is appreciated. Code examples or links to tutorials or other options are much much appreciated :)
Thanks!
You never say it, but I assume you are developing an Android app:
Use HttpClient GET with authentication: an example.
Again use HttpClient GET and look at the reply.

Categories

Resources