Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bài giảng Lập trình cho thiết bị di động: Chương 3 trình bày các nội dung sau: Files, XML Parser, shared Preferences, SQLite, content provider,.! | 1 5. Content Provider 4. SQLite 3. Shared Preferences 2. XML Parser 1. Files 1 2 Uses the same file constructions found in a typical Java application Files can be stored in the device’s (small) main memory or in the much larger SD card. Files stored in the device’s memory, stay together with other application’s resources (such as icons, pictures, music, ). We will call this type: Resource Files. Android Files 3 Data storage options Shared Preferences Store private primitive data in key-value pairs. Internal Storage Store private data on the device’s memory. External Storage Store public data on the shared external storage. SQLite Databases Store structured data in a private/public database. Network Connection Store data on the web with your own network server. 4 1. Files 1.1 Internal Storage 1.2 External Storage 1.3 Saving Cache files 5 1.1 Internal Storage Reading Resource File : Everything in the apk will be read only. And it's even better: android doesn't extract the apk when you install a program, so the size consumed is kept to minimal. 6 1.1 Internal Storage Reading Resource File 7 1.1 Internal Storage If you want to Read and Write an internal file: File is stored in the phone’s memory under: /data/data/app/files 8 1.1 Internal Storage Reading an internal File 9 1.1 Internal Storage Writing an internal File 10 1.2 External Storage Reading/Writing to External Device’s SD card. SD card has the obvious advantage of a larger working space. 11 1.2 External Storage Reading 11 12 1.2 External Storage Writing 12 13 1.3 Saving Cache files To speed up your application’s performance and how often it accesses the network create a cache file. Cache files are stored in the following location on the Android file system: /data/data/app/cache Click icon to pull or push file 14 1.3 Saving Cache files If you'd like to cache some data, rather than store it persistently, you should use getCacheDir() to open a File that represents the internal directory where your application . | 1 5. Content Provider 4. SQLite 3. Shared Preferences 2. XML Parser 1. Files 1 2 Uses the same file constructions found in a typical Java application Files can be stored in the device’s (small) main memory or in the much larger SD card. Files stored in the device’s memory, stay together with other application’s resources (such as icons, pictures, music, ). We will call this type: Resource Files. Android Files 3 Data storage options Shared Preferences Store private primitive data in key-value pairs. Internal Storage Store private data on the device’s memory. External Storage Store public data on the shared external storage. SQLite Databases Store structured data in a private/public database. Network Connection Store data on the web with your own network server. 4 1. Files 1.1 Internal Storage 1.2 External Storage 1.3 Saving Cache files 5 1.1 Internal Storage Reading Resource File : Everything in the apk will be read only. And it's even better: android doesn't extract the apk when you .