-
Notifications
You must be signed in to change notification settings - Fork 16
@BindPreferenceAdapter
xcesco edited this page May 14, 2018
·
2 revisions
This annotation decorates a field to use a particular Shared-Preference Type Adapter to customize persistence on the Shared Preference mechanism. A type adapter must implement the PreferenceTypeAdapter interface. It has two parameter type: the first is the field type, the second is the type that we want to use as replacement and that will be used to store data into the Shared Preference. It implements two methods:
-
toJava
: converts data retrieved from a Shared Preference element. -
toData
: converts a field into data to store into a Shared Preference element.
- adapter: Preference Type Adapter class
@BindSharedPreferences
public class App1Preferences {
@BindPreference
public HashSet<String> valueSet;
@BindPreferenceAdapter(adapter=IntTypeAdapter.class)
@BindPreference
public int right;
}
And the associated SQL type adapter:
public class IntTypeAdapter implements PreferenceTypeAdapter<Integer, String> {
@Override
public IntegertoJava(byte[] dataValue) {
...
}
@Override
public String toData(Integer javaValue) {
...
}
}
This annotation is very useful when you need to persist a class that Kripton does not support directly for persistence.
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction