Android Storing Data - android

I am creating a community app where people can have a profile and search for people - like the soical network kind.
Which is the best way to store data of the logged in User like - User ID, name etc. so that i can use this across the activities for showing data and doing Api calls to get data across the application for the user related content.
What i want to store Locally
User Details like -> userId, Name, Last Known localtion, gender, birthday
Messages Inbox -> threads of conversations between two people.

You can use either SQLite Databases or Shared Preferences Using SQLite Databases will be better If you want to store more information ina astructured manor. But to save small information you can use Shared Preference

Well I guess the best approach is to store data in a database (SQLite), and use a call to sync the data with the server. Like this you can use your app even if you are offline :)
If you store data in memory when you have no internet connection, or you have an internet connection problem, you will get into a lots of trouble.
Good luck,
Arkde

Related

Android applications with SQLite: is sqllite data stored locally on the phone only?

... or can I acess it remotely? If yes, where/how?
To illustrate my question with an example:
If I want to implement a login function and an user creates an account: will his login information only be stored on his phone? (So he can only login on his phone on nowhere else?) Or is it stored somewhere else?
I'm quite confused at the moment and wasn't able to find good ressources zu answer my question (maybe someone knows a good tutorial?)
Thank you in advance for your answers!
There are mainly 3 ways to store data in android:
With the shared preferences, you can save data locally. Its limit is that when you close your app the data are deleted.
With SQLite the limit of the shared preferences is overcome. You can save data into a binary file stored locally in your phone. For use it you have to write some specific java code and inside it write in SQL sintax. It is used for example to keep the highest score in single player game, or simply to let the app remember description, text, user inputs.
With Firebase you can save data in a not local way, data are stored in a server. You can use it for example for develop a social, a game that need to share data with more users, when you have a multiuser application.
This is a data file storage overview, it could be useful too.
For login data it's better to use share preference instead of SQLite. If you use SQLite or Room or share preference, data are saved locally and you can't access them remotely.

What is the best way to store app data and load it in app?

This is just a information question. I'm new to Android app development and currently I'm working on my first app and and it is ready for the release. Now I'm concerned about how to handle heap of users and where to save all their details my app is a service booking app so it needs to save all the order details products details and lots other stuff.
Currently I'm using cloud firestore to load and save all the data of app. But I'm having some issues like without authentication it won't allow users to access some of my data and other. I wonder how large apps save their data and load them perfectly.
I wish someone will help me how can I save all my app data and load them perfectly in app. And suggest me for a best way to manage large user base. And other stuff.
First of all, firestore is good option if you don't have complex backend logic on the database. For simple CRUD operations on data firestore is a good choice but as you said you have a bulk of data then you must go for the Backend database and then connect your database with Rest API. So that all your complex queries will be done on the backend and you can simply consume your API in the app.
If you have lots of data from different users, maybe you should use a central server(DB), something like Postgres or MySQL should work fine.
At the same time, you can also do some sort of caching to accelerate the fetching process, like create a small database locally(you can use Room) to store some user specific data.

What is the best method for storing large paragraph's of text?

I am currently creating a wiki-like application and currently have multiple large paragraphs of text that is required to be stored. What is the best way to store such information? Should I use a database or just put all the information in a text file or even just store the information as a string in xml? The information won't be able to be altered currently by users but I might change that in the future possibly?
Just wondering whats the best method :)
Thanks
For large data it's better to use a database (more control of data flow and more structuring), and keep in mind if you want to work with android database use it just for storing information that is needed when user is not connected to the internet or certain information that is important for the user.
scenario related to your app:
- An article that the user selected as favorite
And keep the unnecessary data on your server.
To use the android database, ROOM is a good start, find the link below to start implementing ROOM in your application:
https://developer.android.com/topic/libraries/architecture/room
If you need further information feel free to ask

Best way to save data in android

I am creating an chat program that communicates with my server at home, so I can send commands. I was wondering what is the best way to save the login information? database? shared preference? sqlite database? file(xml,txt)?
what do you guys think and why?
You can take a look at this article: http://developer.android.com/guide/topics/data/data-storage.html
In my opinion, the best way will depend on the amount of data, if you want to save your login information I'd use SharedPreferences, but if you want to save the login information of many people, I think of using a sqlite database.
Login information contains passwords also, so I would consider this security problem choosing the location to save data.
Login information is usually stored in the server and not in the client: I would definitely choose to store them in a DB.
I suggest to encrypt passwords if you want to save them in a DB (SQLite, MySql or whatever).
For further information I suggest to take a look here:
Android: Storing username and password?

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.

Categories

Resources