"Android" mobilių programėlių kūrimo įvadas #3


Published on

Mobilių programėlių Android operacinei sistemai kūrimo paskaita, kurią veda UAB "App Camp" Android guru Vykintas Valkaitis.

Pagrindinės paskaitos temos:
SQLite duomenų bazė
Adapteriai ir greitas sarašų atvaizdavimas
GPS biblioteka
Google maps integracija
Camera biblioteka
Unit testai

Published in: Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

"Android" mobilių programėlių kūrimo įvadas #3

  1. 1. Androidmobilių programėlių kūrimo įvadas
  2. 2. Storage OptionsAndroid provides several options for you to savepersistent application data.Shared Preferences - Store private primitivedata in key-value pairs.Internal Storage - Store private data on thedevice memory.External Storage - Store public data on theshared external storage.SQLite Databases - Store structured data in aprivate database.
  3. 3. SharedPreferences - getSharedPreferences() - Use this if you need multiple preferences files identified by name, which you specify with the first parameter. - getPreferences() - Use this if you need only one preferences file for your Activity. To read values, use SharedPreferences methods such as getBoolean() and getString(). To write values: 1. Call edit() to get a SharedPreferences.Editor. 2. Add values with methods such as putString(). 3. Commit the new values with commit()
  4. 4. Internal Storage To create and write a private file to the internal storage: 1. Call openFileOutput() with the name of the file and the operating mode. This returns a FileOutputStream. 2. Write to the file with write(). 3. Close the stream with close().
  5. 5. External Storage If youre using API Level 7 or lower, use getExternalStorageDirectory() to open a File that represents the root of the external storage, then save your shared files in one of the following directories: Music/ - Media scanner classifies all media found here as user music. Podcasts/ - Media scanner classifies all media found here as a podcast. Ringtones/ - Media scanner classifies all media found here as a ringtone. Alarms/ - Media scanner classifies all media found here as an alarm sound. Notifications/ - Media scanner classifies all media found here as a notification sound. Pictures/ - All photos (excluding those taken with the camera). Movies/ - All movies (excluding those taken with the camcorder). Download/ - Miscellaneous downloads.
  6. 6. Databases Android provides full support for SQLite databases. Any databases you create will be accessible by name to any class in the application, but not outside the application. The recommended method to create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method, in which you can execute a SQLite command to create tables in the database.
  7. 7. Databases You can then get an instance of your SQLiteOpenHelper implementation using the constructor youve defined. To write to and read from the database, call getWritableDatabase() and getReadableDatabase(), respectively. These both return a SQLiteDatabase object that represents the database and provides methods for SQLite operations.
  8. 8. GPS GPS_PROVIDER This provider determines location using satellites. Depending on conditions, this provider may take a while to return a location fix. NETWORK_PROVIDER This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup. PASSIVE_PROVIDER A special location provider for receiving locations without actually initiating a location fix.
  9. 9. Google Maps The Google Maps Android API v2 uses a new system of managing keys. Existing keys from a Google Maps Android v1 application, commonly known as MapView, will not work with the v2 API. To access the Google Maps servers with the Maps API, you have to add a Maps API key to your application. The key is free, you can use it with any of your applications that call the Maps API, and it supports an unlimited number of users.
  10. 10. Google Maps An Android application that uses the Google Maps Android API needs to specify the following settings in its manifest file, AndroidManifest.xml: Permissions that give the application access to Android system features and to the Google Maps servers. Notification that the application requires OpenGL ES version 2. The Maps API key for the application. The key confirms that youve registered with the Google Maps service via the Google APIs Console.
  11. 11. Camera
  12. 12. Q&Av.valkaitis@appcamp.lt