I have an app which links to an dropbox account. I am able to login once and is saves that. But each time it asks whether I want to allow access to the app or not . Is there a way to save this preference as well and provide access to the app permanently ?
Read again https://www.dropbox.com/developers/start/authentication#android especially "Return to your app after user authorization".
After successful .getSession().finishAuthentication() there is AccessTokenPair tokens = mDBApi.getSession().getAccessTokenPair() which will give You data, which You should save somewhere for later use (You can use SharedPreferences for this).
In start time of application You have to check existance of this saved data, and if it's there, You don't have to call .startAuthentication() again, instead You should call .setAccessTokenPair(access) with saved data as access (look at top of https://www.dropbox.com/developers/start/files#android ).
Related
This question is about the new GoogleSignInApi explained here.
Suppose I go through the steps and I acquire the email, first name, last name and for good measure an Id.
Suppose I save all this information on the device (either via Preferences or via SQLite) so that in future I don't need to ask the user for his authorisation again.
The question is how to make sure that the Id and the info is still valid,
Perhaps by next time, the user has revoked his authorisation, or that he has changed some of the profile info.
Now before you answer that I have to use SilenSignIn, let me say, that silent sign in won't work. Because for the Initial signin I use another Activity called through startIntentForResult after I get the profile I close that activity, I don't want to have to call that activity again, because the point of saving the information is not to call the activity again.
I'm worried about android security. I am storing the user id in sharedpreferences. I see some programs online that allow you to get into the sharedpreferences if your device is rooted... etc...
How do I prevent my sharedpreferences from being changed?
There is no way to avoid a user being able to change shared prefs. You need to implement security on your back end with session tokens so that even if the front end userid is changed the back end doesn't allow you to make requests because the session token doesnt match the user id. I assume you are asking because you are having you app communicate with a server and dont want the user to be able to see other peoples data. if not may i ask why you need to be able to do this?
read more about them here
Session token - how does it work?
Code like this
SharedPreference mySP = PreferenceManager.gerDefaultSharedPreference(this, Context.MODE_PRIVATE);
Only your app can access this...
I am developing a Application which will create events in calendar. Events should get created only once when my application is installed and opened. I tried with using Shared preferences. But when i clear my app data, shared preferences were also getting cleared.
Please let me know how to do this.
Although Shared preferences is usually used for the use case like yours, but since you wants to be guarded against "Clear Data", You may create an empty file as an alternative.
You can check (before creating a Cal.event) if your file(whose exact name and location is only known to you) exist.
Obviously, there are many situations with this approach against which you need to protect.
1.what if user removes this file?
2.if you chose to save file on SD-card, what if sdcard is removed?
In case, if you do not want to rely on Device and data saved on device, and if your app can communicate with Server, then you can maintain this installation history information "online". Then, invoke a network call to query "installation history" info.
For this method to work, you also needs to track on which device and user, the installation was done previously.
I have this android app with user login and app settings.
app settings are save in default location com.package_preference.xml
when user logins. he or she can set the app settings like notification. or vibrate.
my problem is when another user logins every app settings set by the last user logged in will be use since it was stored localy.
any ways to handle this issue? or better ways to avoid this problems?
I was thingking saving that file on sqlite but that was a lot of work to do.
or name the preference file like user_id_preference.xml but i dont think this is feasible since app preference are save as com.package_preference.xml
I want to be able to prompt the users to enter the details required for the app only when it starts up for the first time (not other times). These details will be held in a database on the phone.
Would it be better to check the database each time or put these details in a shared preference? Furthermore, is this type of activity even possible on Android?
Depends on the details really. If it is a large amount of information you might consider using a Database. For just basic identification information, SharedPreferences should be fine.
If you do use a Database, you might consider loading them into your Application object. This would depend on how frequently you use this information in your app.
To check for the first start of the app, a SharedPreference is generally used AFAIK.
Use SharedPreferences or Database depending on the data complexity and its need later on..
Store a Flag in SharedPreferences and set this when user enters the data.
Check that shared preferences flag while on your first activity and redirects accordingly(to Details/one time page) if required.
here even if a user manually deletes data using Settings > Manage app > your app > clear data, Your app will know to get the details then from user....