티스토리 뷰
유용한 안드로이드 라이브러리 simple-shared-preferences
Park, Woocheol 2018. 5. 13. 00:16simple-shared-preferences
simple uses shared-preferences support generic and rxjava for andoird
Initialize
public class DemoApplication extends Application {
@Override
protected void onCreate() {
super.onCreate(savedInstanceState);
// apply default shared preferences file name.
SimpleSharedPreferences.initialize(this);
// apply custom shared preferences file name.
SimpleSharedPreferences.initialize(this, "custom file name");
}
}
Example
public class DemoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// put value
// supported value type : String, Set<String>, long, int, float, boolean, T
SimpleSharedPreferences.put(key, value);
// get value
SimpleSharedPreferences.getValue(key, defaultValue);
// get T
SimpleSharedPreferences.getValue(key, class);
// Rx
SimpleSharedPreferences.Rx.put("demo","demo value").subscribe(value -> Log.d("demo",value));
SimpleSharedPreferences.Rx.getValue("demo","demo value").subscribe(value -> Log.d("demo",value));
}
}
Download
Maven:
<dependency>
<groupId>com.parkwoocheol</groupId>
<artifactId>simple-shared-preferences</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
Gradle:
implementation 'com.parkwoocheol:simple-shared-preferences:1.0.2'
RxJava might not be available to the class loader. This can result in an exception that looks like this
Error:(20, 35) error: cannot access Observable
class file for io.reactivex.Observable not found
This can be fixed by either adding RxJava to your project Gradle:
// see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version
implementation 'io.reactivex.rxjava2:rxjava:2.x.x'
implementation 'com.parkwoocheol:simple-shared-preferences:1.0.2'
Developed By
- Park, Woocheol - mrparkwc@gmail.com
License
Copyright (C) 2018 Park, Woocheol
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'Programming Story > Android' 카테고리의 다른 글
유용한 안드로이드 라이브러리 SimpleLog (1) | 2018.04.14 |
---|
- Total
- Today
- Yesterday
- 오뎅나베 맛집
- 페이스북 맛집
- 로그 라이브러리
- 오뎅탕 맛집
- 남천동 맛집
- 초대장
- 경성대 꽃집
- 레오폴드
- 페북 맛집
- 티스토리 초대장
- 부산 맛집
- 부산
- 부산맛집
- 맛집
- 노는바다
- Android
- 제주도여행
- Tistory 초대장
- 한우
- 부경대 맛집
- 제주도가볼만한곳
- 야키토리 전문점
- 인스타 맛집
- Tistory
- Surface Precision Mouse
- 안드로이드 라이브러리
- 티스토리
- 야키토리 맛집
- Java
- 소설담
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |