-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into main
- Loading branch information
Showing
1 changed file
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,51 @@ | ||
# Prefs.io | ||
An easy Shared Prefs library with more options : ) | ||
A small and easy Shared Prefs library with more options : ) | ||
|
||
# Implementation | ||
<p>Add jitpack to your maven sources</p> | ||
<div class="highlight highlight-source-groovy"><pre>allprojects { | ||
repositories { | ||
<span class="pl-k">..</span>. | ||
maven { url <span class="pl-s"><span class="pl-pds">"</span>https://jitpack.io<span class="pl-pds">"</span></span> } | ||
} | ||
}</pre></div> | ||
<p>Add Censory as a dependency to your <code>build.gradle</code></p> | ||
<div class="highlight highlight-source-groovy"><pre>dependencies { | ||
implementation <span class="pl-s"><span class="pl-pds">'</span>com.github.KapilYadav-dev:Prefs.io:CURRENT_RELEASE<span class="pl-pds">'</span></span> | ||
}</pre></div> | ||
|
||
|
||
# Usage | ||
1) Initialization ( in application class ) | ||
2) Use it 👨🏽💻 | ||
|
||
# Initialization | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
// Initialize the Prefs class | ||
SharedPrefs.init(this); | ||
} | ||
|
||
|
||
|
||
# Use it | ||
After initialization, you can use simple one-line methods to save and get those values from the shared preferences anywhere in your app, such as: | ||
|
||
<ul> | ||
<li><code>SharedPrefs.setString(key, string)</code></li> | ||
<li><code>SharedPrefs.getString(key, defaultString")</code></li> | ||
<li><code>SharedPrefs.setInteger(key, int)</code></li> | ||
<li><code>SharedPrefs.getInteger(key, defaultInt)</code></li> | ||
<li><code>SharedPrefs.setboolean(key, boolean)</code></li> | ||
<li><code>SharedPrefs.getboolean(key, defaultBoolean)</code></li> | ||
</ul> | ||
|
||
# Use it with encryption | ||
## It's a better practice to encrypt down your sharedPrefs so that it can't be altered by Root Piratess 🏴☠️ | ||
<ul> | ||
<li><code>SharedPrefs.setString(key, string, encryptionKey)</code> // This will encrypt your String 🤐</li> | ||
<li><code>SharedPrefs.getString(key, defaultString, encryptionKey, encryptedText)</code> // This will decrypt down your encrypted String 😎</li> | ||
</ul> | ||
|