SharedPreferences
- Persistent Map of simple data types
- Automatically persisted across application sessions
- Used for store long-term storage of customizable application data
Get a SharedPreferences object
- Activity.getPreferences(int mode)
Get a specific SharedPreferences
- Context.getSharedPreferences(String file, int mode)
- file - name of SharedPreference file
- Get Values
- getAll()
- getBoolean(...)
- getString(...)
Write SharedPreferences
- SharedPreferences.edit()
- putInt(...)
- putString(...)
- remove(...)
Save changes
- SharedPreferences.Editor.commit()
PreferenceFragment
- Display user preferences that can be modified
Memomry
- Internal
- Application private data sets
- External
- non-private data sets
- Determine the status of external memory
- Environment.getExternalStorageState()
- Results
- MEDIA_MOUNTED
- MEDIA_MOUNTED_READ_ONLY
- MEDIA_REMOVED
- Permission
- android.permission.WRITE_EXTERNAL_STORAGE
Cache Files
Get an instance
- File Context.getCacheDir()
- Return absolute path to an application-specific directory for temporary files
- Context.getExternalCacheDir()
- Returns a dile representing external storage directory for cache files
SQLite
Designed to operate < 300 kb- Use as recomendation a helper SQLiteOpenHelper
- Follow the next steps
- Create a subclass
- Call method super() to initialize underlying DB
- Override onCreate()
- Create the tables using CREATE TABLE
- Override onUpgrade()
- Use SQLiteOpenHelper methods to open the DB
- Execute operations
- DB Path
- /data/data/<package name>/databases
SQLITE3
- Use to examine the DB
- #adb -s emulator-5554 shell
- Open the connection
- #sqlite3 /data/data/<package name>/databases/<DB_name>
- <package name> - course.examples.DataManagement.Data.BaseExample
- <DB_name> - artist_dbd
Comentarios
Publicar un comentario