Skip to content
This repository was archived by the owner on Mar 1, 2022. It is now read-only.

First time initialization with an empty string as password is very slow, it typically takes 4 seconds on every device #64

Open
Rkdroid opened this issue May 22, 2017 · 5 comments

Comments

@Rkdroid
Copy link

Rkdroid commented May 22, 2017

private SecurePreferences mSecurePrefs;
private SecurePreferences openSharedPrefs(){
if (mSecurePrefs == null) {
mSecurePrefs = new SecurePreferences(context, "", "sec_prefs.xml");
}
return mSecurePrefs;
}

Usage:
PreferenceManager pref = new SharedPreferencesManager(context);
String text = pref.getText();
The first time initialisation of preferences takes lot of time, on average 4 seconds, which is really frustrating for the user. have implemented this library at the first time launch of the app and lot of users are complaining that app never loads because of this issue.

Can you please help to improve the speed of initialization with respect to the above scenario.

Thanks

@miklendap
Copy link

@Rkdroid See Issue #18 and mentioned PullRequest #48. With this you can significantly reduce initialization time (in my case it was about 50% faster).
But unfortunately even if PullRequest #48 was merged at 31 Aug 2016, current version of SecurePreferences (0.1.4) does not contain this changes. So you can fork, or add updated SecurePreferences class directly into your project.
Or maybe could @scottyab release new version containing PullRequest #48, couln't he? 😄

@scottyab
Copy link
Owner

scottyab commented Jun 22, 2017 via email

@miklendap
Copy link

Hi @scottyab,
any update with this issue and new Lib version release?
Also e.g. issue #31 (crash on API 16) should be solved with new release.

Thanks in advance.

@scottyab
Copy link
Owner

Hey @miklendap @Rkdroid I'm in the middle of sorting a 0.1.5 release to include the most recent changes. In terms of the slowness that's something I'll be addressing in next version to make it down to the developer to choose fast/less secure or slow/more secure. Thanks for the feedback.

@danilodequeiroz
Copy link

danilodequeiroz commented Sep 26, 2018

You can keep your SecurePreferences instance as a singleton and create it on your Application class along with Fabric and others stuffs, my app has a splash screen (with a drawable in theme's background) so the user won't notice the delay.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants