Authendication data Store in android - android

I Know If the User have to Store UserName and Password then we can create Class and store the UserName and Password in Class. At get the data using SharedPreferences for that class.But That class store the data upto we can not close the Application. If we close the Application then data will be destroyed.
My Question is :
I Want to Store Data in Application if the User close the application or Restart the Mobile device. But the data are Store in the Class. How to perform this task. I am new to android. Please Help me.

You are new to Android. So, you should go through this link. You got these many Storage options in Android: http://developer.android.com/guide/topics/data/data-storage.html
In your case, You can go with SharedPreferences. Your data will be stored in key-value pair. And also, it is persistent storage.

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.

Storing user data in from api in "session"

I am not sure of the best way to do this, when user logs in my app i want to store his data from an api. I will be using this data trough out the app, so i dont call getUserData all the time . So i want to ask for an opinion
Do i store user data in application context so i can access it in all activites/fragments
Or
Do i store the user data in SharedPreferences as json string (User has a lot of small data name,lastname,age,email...)
Or
Do i store it in database (Since i only need storing for this i tought this way might be too much, but could be wrong)
Or
There might be a better way to do this?
SharePreferences are great, but it is stored in plain text and can be read by rooted devices. Someone with a stolen rooted phone can potentially access tons of user info.
Use a library like:
https://github.com/scottyab/secure-preferences
To encrypt the preferences or use a secret key to encrypt and decrypt the data.
You can initialized the user object on the OnCreate of your Application Object this way. Have you app instance be a singleton and you can access this user object object amongst your activities and fragments.

Save And Retrieve Data In Multiple Activites Android Studio

I'm new in android, I am developing web application by android studio.
When user open application, there is activity login. User need input ipaddress of server, username and password before access application.
What I want to know, Is it possible to save ippaddress and other data to something like SEASSON/Cookies Web in Android Studio? So user only need 1 time to input data, store it and ALL activity inside application will get that data everytime it needed.
Thankyou my friends.
If you want to keep the User's Login data locally, encrypt the values and store it in Shared Preferences or in SQLite Database.
I think storing it locally is the best option because it wouldn't require your app to make network calls every time user opens the app.
Here are my suggestions:
1. If you have a web service, encrypt and persist the values securely to your web service via a post
2. Encrypt and store the values in shared preferences
3. Encrypt and store the values in a sqlite data base on the device.

I want the data to be permanent store in my Android app

I want to store data like in Shared Preference or SQLite in my app . So that the data doesn't get deleted when we clear app data . Infact when we clear data of whatsapp we have to register again,it's registration data also get deleted.But I want to store permanently that first registration data.Is there any way for that?
No. Everything of an app gets cleared when the user either clicks "Clear Data" or uninstalls-and-reinstalls the app.
You can use SDCARD to store data on external storage.
Data will be available until sdcard format or delete your custom storage folder.
You can use BackupManager to store data and restore it, or you can write your own server application to store this data based on device_id, which you can later restore based on device_id

Session time-out in webservices

I am developing a Restful Webservice using Eclipse and an android application. User logs in using its username and password on the android application which is checked against the database at the server side(using this web service).
Now, I want to maintain a session for which the user will remain logged in, that is, the user does not have to log in again and again whenever he re-opens the application.
How to do it? I searched on net but I could not find an accurate solution. Kindly help with the appropriate solution. Ask if more information is required.
use Shared Preferences to save session data .
there are good tutorials :
http://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/
http://androidexample.com/Android_Session_Management_Using_SharedPreferences_-_Android_Example/index.php?view=article_discription&aid=127
This can be done in two ways. One is storing them in a global variables and second is storing the data in shared preferences. The problem with storing data in global variable is data will be lost once user closes the application, but storing the data in shared preferences will be persistent even though user closes the application. Here is the complete example:
http://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/

Categories

Resources