How to communicate with xml file in android - android

My app should have capability to work online and offline.
When I have internet, I will connect to tomcat server and fetching the json object and displaying the details.
But if I don't have internet access, I want my app to work. So my idea was to store the data in xml files in mobile at some folder when my last communication done with server. Is it possible?
If so how can I do it.. Can anybody help me ???

You can store the data in your internal memory and every time you hit the server delete the old contents.

Maybe you can use Preferences or a database

Related

Recover an image from an android to send to server

I am currently working on an android application and I would like to add a file system to send images. But I don't know how to get an image from the local storage of an android, nor how to send it to a server. I am currently using a flask server to retrieve JSON files, and I don't know if retrieving images would be possible with this kind of server.
Would you have any clue how to retrieve a file on a button press and send it to a server please?
You can use this library to pick from local storage and upload it to the server with ease
https://github.com/gotev/android-upload-service
At this point, it doesn't matter what server you use as long as you can retrieve data.
You can do it using Retrofit. For detailed instruction, check This medium post!

which is best option to publish android app with local database?

I am developing an app in which i would need a local database.
So as per my knowledge there are two ways to do it:
First is to add pre filled database file in assets folder & make copy of local database from it the very first time app is started.
Second is using script to download it from Server for first time of app use?
First way have been pretty well answered by this guy Using your own sqlite database in android application
Can someone help how can i go with second way of download data from Server?
Should i use JSON/XML for getting that data from my Server?
Or should i go with first option since my app has only around 150 to 200 rows in the db file?
Go for the local db for the following reasons:
The users would have great on boarding experience as they can very quickly start seeing the utility of the app since you provide some data on first run without any delay that might be added when you fetch data from the server.
Do it for sure if the db doesn't increase the apk size significantly.
You must use php only if you need get information from the server, with php and json is better ...
http://www.vogella.com/articles/AndroidJSON/article.html
and if you only need share local information, only needs use MYsqLite ...
http://www.vogella.com/articles/AndroidSQLite/article.html

How do I read in a single line from an external text file (on server) to display in Android activity?

we have a text file stored on our server where I work, and I have searched on how to read in a specific line from that text file and have it display on the screen of my Android activity... but I haven't found a solution yet. Only two words, or so, of the text in the file on the server will be changed/replaced periodically, and I would like those changes to take effect/be updated in my Android app each time. Not sure why I couldn't find an answer to this yet. Any help is much appreciated! Thank you!
Actually the best way to have a secure transaction between an android app and server is to use web service like JSON. You request something from your android app to server, Then in server request will be analyse and response to your android app. You can send some request that tell the server what to do. Then in server side have a script that do your job and send response to your android app.

Storing Local Data on Android Phone and then uploading with Google Spreadsheets

I am developing an android application for rural villages where 3g access is not always present. The application will be based out of a Google Spreadsheet. It should be such that if there is no internet access, new data entered will be stored on a local file and when there is internet connection, it will automatically sync with the online file. What is the method to properly proceed with this? Can i store a local excel file or something similar and then sync that file with the online google spreadsheets? Are they even compatible?
Sorry for the many questions but any help will be great!
The usual way to store structured data on Android is to use an sqlite database. Save your data , then just copy it to the Google spreadsheet using the API. If you want to get fancy, you can write a sync adapter and let the OS schedule it for you. Not sure how well that is going to work if connections are unreliable though.
MyTracks is an open source that does something similar, you can use it as a reference: http://code.google.com/p/mytracks/

How to transfer SQLite db to web server on android phone

I have an application that creates an SQLite database and saves
information to it over the course of a day. At the end of the day i
want to export this database to a web server.
Could anyone point me in the right direction for this?
Should I use httppost or put. I have researched this myself online but
there seems to be so many different ways to explore. The server side
does not exist yet either. I have access to an apache server so i am
hoping to use that.
Could anyone advise me the best/most simple way to do this?
Thanks guys,
Just wanted to let you know that i used the intent provided by the andFTP app in the end. Its very simple to use and details can be found at: http://www.lysesoft.com/support/forums/viewtopic.php?f=5&t=158
Couple of ways ...
you can ftp up the db each day
you can export the data to a csv file and post it to the server; once there you can then import it into the db on the web server
Is it for backup purposes? Or do you require a number of dbs on the web server?
Do you want this to be an automatic or manual transfer? SQLite data is just a file, so (from the SQLite site)... "If SQLite can read the disk file then it can read anything in the database. If the disk file and its directory are writable, then SQLite can change anything in the database. Database files can easily be copied onto a USB memory stick or emailed for sharing." So (provided everything your app needs is set up on the server) just move the file to the server.

Categories

Resources