Where should I store the RESTful data in Android? - android

I need to build an android application that communicates with a REST WebService. All operations will be performed online and there are few objects/data that need to be stored in the device memory. I run through RESTDroid but it seems to be "too much" for my needs. Should I store the objects in the file system/sd card? What are the advantages/disavantages of this approach?
Thanks.

If you have many same objects, that you receive from your web service, you should use SQLite database. If you have few objects you can serialize it and store in file or serialize it as JSON for example and store in SharedRreferences. I dont know the best way for you, but for me it would be SQLite database or SharedPreferences.
Good luck!

you can look into this tutorial in which he explained so beautifully to store SMALL RESTful data

Related

Save data in sqlite date base from a webservice

I am new to android and I am facing a problem in one of my applications. The data is coming from a webservice in Json format. I need to save that data in my local database and work with it only through out the application and at the end upload the data back to the server. Basically I need to make an offline app but I am not getting how to start and manage this flow. Any help regrading this.
Thanks in advance.
If I understand correctly your problem you need to create an offline application using SQLite.
I can't, obviously, write you a full blown SQLIte tutorial but here are some links that might help you in learning how to create such an application.
First of all, in order to persist your data you might want to use Room, Room is the official SQLite ORM created for Android by Google's teams. It will allow you to persist data directly in your database without having to write a lot of boilerplate code.
Then you would need a JSON Parser. I use GSON which works perfectly fine but many others exists like JACKSon for example.
Now, what you need is an offline synchronization strategies. There are many ways of synchronizing your application with your webservice and there is no miracle solution every application will have a different use case. However here are a couple of links that explain some strategies and when to use them.
Offline data synchronization, Part1 : Basic strategies to address this critical challenge for mobile apps
Offline data synchronization, Part 2: Advanced strategies to address a crucial challenge for mobile apps
Then again, your question is too generic to get a specific question. I hope this collection of links will help you in your project.
Cordially,
Matthieu
JDXA ORM for Android can help your app save the JSON data in a device-local SQLite database. Using JDXA, you may then work with the saved data in your app through a more convenient POJO object model. You may retrieve the saved/updated data from SQLite in JSON format and send it to the server when needed. You don't need any JSON parsers. Disclaimer: I am the architect of JDXA ORM.

android, storing data on web server without database?

is there a way to store information (strings, numbers, booleans) on a webserver without using a database(mysql, sqlite, etc...) in android?
similar to how vb can read/write to a access "database" by only using a single file.
Thank you
You can write into json file as save it in server. For best approach, it is recommended to use database. Easier to do CRUD operations.
For store information into android application u can use SharedPreferences.about SharedPreferences
Or ,You can used a lib for store all data ObjectCache

Android light and fast way to implement data storage from Api Rest service

I'd have to implement a simple app that retrieves some data from Api Rest service through JSON and save them to internal data storage.
Until now, I'm using AsynTask custom class for each call but it seems a complicated and slow process to retrieve json, check, parse and save it to storage ( I'm usic DBHelper with an SQLLite DB ).
I don't need to manage a large amount of data, I need to manage events with some strings, an image url, and some dates.
The important is having a fast process to load/update/storage/retrieve information from API Rest Service to android internal storage.
What is the best solution to implement it?
Thank you guys
First of all: Don't reinvent the wheel and use successful libraries for API / database handling. This will save you tons of (debugging) time. Have a look at the Android Arsenal for the libraries fitting your needs. For a clean architecture have a look at these samples.
To get information from RestApi I would recommend a retrofit. It let you get data very easy and convert it to lot's of different format.
If you will use gson then retrofit can convert your data from server directly to objects. And then just sabe this objects to you local db.
Different ORM libraries let you do that very easy.

How to store multiple List<NameValuePairs> for later post to server?

I want to be able to store multiple List<NameValuePairs> for when multiple users enter information into my Android application using the same device. Later on, the user should then be able to send their data to the server at a click of a button. But this should only be for later upload for example when there is wifi/network connectivity.
What is the best way to go about storing these List<NameValuePairs>?
Well, your best bet is to store the data in Android's SQLite database:
http://developer.android.com/guide/topics/data/data-storage.html#db
As an alternative you can just serialize your objects to a file, but that might be too much of a hussle if the data is big.
Then you can have a service that runs in the background and sends data from the local db to the server when possible.
Here are your storage options:
http://developer.android.com/guide/topics/data/data-storage.html
I would imagine that depending on the kind of data and size, SharedPreferences or SqlLite could be useful for you. You can back DB with a ContentResolver and implement sync (SyncService) to upload to server. In this case, the Android OS will intelligently sync your data on the cloud when network is reachable.
Decided to save everything as a long string of name value pairs seperated by ampersands for easy upload to database when sending to php server.

Android SQLite and Data storage Pros/Cons

What is the best way for an app to push and pull data from an external database?
I want users of my app to be able to write to the database as well as view record data.
Would I use a SqLite database on a webserver somewhere? Does the database type make a difference?
Would an XML file work?
I am thinking that I can have data in my app. So, as users write new records, other users would be able to see those updates.
Suggestions? Comments? What's the best way to do this?
I personally use a local SQLite db on the android, that uses HTTPposts to interact with php on my webserver, which then accesses a mySQL instance. Communication is done through serialized JSON objects as text, gzipped. Transfers about 50kb of raw text as 10kb compressed, very manageable.
Theres lots of excellent tutorials here and otherwise, if you do a little googling for httppost android.
It is generally recommended NOT to have your mobile device have direct access to the online database, for better security and abstraction. Besides php can do some great stuff like doubly validate inputs.

Categories

Resources