SlideShare a Scribd company logo
ANDROID TRAINING
SESSION – 4
-Hussain KMR Behestee
AGENDAS
• Shared Preferences
• Storages
• SQLite Database
– SQLite Open Helper
• Content Providers
– SQLite Programming
• Content Providers
Shared Preferences
• The SharedPreferences class provides a general framework that allows
you to save and retrieve persistent key-value pairs of primitive data types.
• You can save any primitive data: booleans, floats, ints, longs, and strings.
This data will persist across user sessions (even if your application is
killed).
• use one of two methods:
– getSharedPreferences() - Use this if you need multiple preferences files
identified by name.
– getPreferences() - Use this if you need only one preferences.
• Call edit() to get a SharedPreferences.Editor
• Add values with methods such as putBoolean() and putString().
• Commit the new values with commit()
• To read values - getBoolean() and getString()
Internal Storage
• You can save files directly on the device's internal storage. By default, files
saved to the internal storage are private to your application and other
applications cannot access them (nor can the user). When the user
uninstalls your application, these files are removed.
• To create and write a private file
– Call openFileOutput() with the name of the file and the operating mode. This
returns a FileOutputStream
– Write to the file with write()
– Close the stream with close()
• To read a file
– Call openFileInput() and pass it the name of the file
– Read bytes from the file with read()
– Then close the stream with close()
• Other useful methods: getFilesDir(), getDir(), deleteFile(), fileList()
External Storage
– Checking media availability - Before you do any work with the
external storage, you should always call getExternalStorageState() to
check whether the media is available.
– Accessing files on external storage
• If you're using API Level 8 or greater, use getExternalFilesDir() to open a File
• If you're using API Level 7 or lower, use getExternalStorageDirectory()
– You should then write your data in the following directory:
• /Android/data/<package_name>/files/
• If the user's device is running API Level 8 or greater and they uninstall your
application, this directory and all its contents will be deleted.
– Hiding your files from the Media Scanner
• Include an empty file named .nomedia in your external files directory
External Storage
– Saving files that should be shared - These directories lay at the root of
the external storage
• 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.
– Getting Shared Files
• In API Level 8 or greater, use getExternalStoragePublicDirectory(), passing it the
type of public directory you want, such as DIRECTORY_MUSIC,
• If you're using API Level 7 or lower, use getExternalStorageDirectory()
SQLite Database
– 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.
– to create a new SQLite database is to create a subclass of
SQLiteOpenHelper and override the onCreate() method. You should
use it to Create Table
– To Upgrade your database use onUpgrade() method. You should use it
to Alter Table
Android Content Provider
App 1
(Dialer)
App 2
(Messaging)
App 3
(Custom)
App 4
(Custom)
Content Provider 1
Data can be shared over different applications
Content Provider Basics
1. There are no common storage area that all Android application can access.
2. The only way: to share data across applications: Content Provider
3. Content providers store and retrieve data and make it accessible to all
applications.
Content Provider 2
Android Content Provider
Content Provider Basics (Contd.)
Android ships with a number of content providers for common data types:
1. Audio
2. Video
3. Images
4. Personal contact information etc
Content Provider provides the way to share the data between multiple applications.
For example, contact data is used by multiple applications (Dialer, Messaging etc.)
and must be stored in Content Provider to have common access.
A content provider is a class that implements a standard set of methods to let other
applications store and retrieve the type of data that is handled by that content provider.
Content Provider
data
App 1
App 2
Android Content Provider
Querying Data
Content Provide: URI
1. Each content provider exposes a public URI that uniquely identifies its data set.
2. A content provider that controls multiple data sets (multiple tables) exposes a
separate URI for each one.
3. All URIs for providers begin with the string "content://".
The content: scheme identifies the data as being controlled by a content provider.
URI samples:
<standard_prefix>://<authority>/<data_path>/<id>
For example, to retrieve all the bookmarks stored by our web browsers (in Android):
content://browser/bookmarks
Similarly, to retrieve all the contacts stored by the Contacts application:
content://contacts/people
To retrieve a particular contact, you can specify the URI with a specific ID:
content://contacts/people/3
Android Content Provider
Content Provide: URI
So we need three pieces of information to query a content provider:
1. The URI that identifies the provider
2. The names of the data fields you want to receive
3. The data types for those fields
If we are querying a particular record, you also need the ID for that record.
Some more examples:
content://media/internal/images URI return the list of all internal images on the device.
content://contacts/people/ URI return the list of all contact names on the device.
content://contacts/people/45 URI return the single result row, the contact with ID=45.
QUESTION?
THANK YOU

More Related Content

What's hot

"Android" mobilių programėlių kūrimo įvadas #3
"Android" mobilių programėlių kūrimo įvadas #3"Android" mobilių programėlių kūrimo įvadas #3
"Android" mobilių programėlių kūrimo įvadas #3
Tadas Jurelevičius
 
android content providers
android content providersandroid content providers
android content providersDeepa Rani
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
Wingston
 
CSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachCSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachbutest
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)
Khaled Anaqwa
 
Directory structure
Directory structureDirectory structure
Directory structure
sangrampatil81
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsing
Aly Arman
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
Sourabh Sahu
 
Chapter 6 Java IO File
Chapter 6 Java IO FileChapter 6 Java IO File
Chapter 6 Java IO File
Khirulnizam Abd Rahman
 
SQLite Database Tutorial In Android
SQLite Database Tutorial In AndroidSQLite Database Tutorial In Android
SQLite Database Tutorial In Android
Android 5
 
Unit 4 File and Data Management
Unit 4 File and Data ManagementUnit 4 File and Data Management
Unit 4 File and Data Management
Soushilove
 
Unit 4 file and data management
Unit 4 file and data managementUnit 4 file and data management
Unit 4 file and data management
Soushilove
 
Python Tutorial-Mining imgur images
Python Tutorial-Mining imgur imagesPython Tutorial-Mining imgur images
Python Tutorial-Mining imgur images
Weiai Wayne Xu
 
Lab4 - android
Lab4 - androidLab4 - android
Lab4 - android
Lilia Sfaxi
 

What's hot (14)

"Android" mobilių programėlių kūrimo įvadas #3
"Android" mobilių programėlių kūrimo įvadas #3"Android" mobilių programėlių kūrimo įvadas #3
"Android" mobilių programėlių kūrimo įvadas #3
 
android content providers
android content providersandroid content providers
android content providers
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
 
CSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachCSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approach
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)
 
Directory structure
Directory structureDirectory structure
Directory structure
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsing
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Chapter 6 Java IO File
Chapter 6 Java IO FileChapter 6 Java IO File
Chapter 6 Java IO File
 
SQLite Database Tutorial In Android
SQLite Database Tutorial In AndroidSQLite Database Tutorial In Android
SQLite Database Tutorial In Android
 
Unit 4 File and Data Management
Unit 4 File and Data ManagementUnit 4 File and Data Management
Unit 4 File and Data Management
 
Unit 4 file and data management
Unit 4 file and data managementUnit 4 file and data management
Unit 4 file and data management
 
Python Tutorial-Mining imgur images
Python Tutorial-Mining imgur imagesPython Tutorial-Mining imgur images
Python Tutorial-Mining imgur images
 
Lab4 - android
Lab4 - androidLab4 - android
Lab4 - android
 

Viewers also liked

Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add ons
Vincent Clyde
 
Database
DatabaseDatabase
Rajab Davudov - Android Database
Rajab Davudov - Android DatabaseRajab Davudov - Android Database
Rajab Davudov - Android Database
Rashad Aliyev
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
Mark Lester Navarro
 
Video Streaming: from the native Android player to unconventional devices
Video Streaming: from the native Android player to unconventional devicesVideo Streaming: from the native Android player to unconventional devices
Video Streaming: from the native Android player to unconventional devices
Alessandro Martellucci
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
MaryadelMar85
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...
BeMyApp
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
Perfect APK
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for AndroidJakir Hossain
 
Xamarin Traditional Approach & Xamarin.Forms
Xamarin Traditional Approach & Xamarin.FormsXamarin Traditional Approach & Xamarin.Forms
Xamarin Traditional Approach & Xamarin.Forms
William S. Rodriguez
 
Android AsyncTask Tutorial
Android AsyncTask TutorialAndroid AsyncTask Tutorial
Android AsyncTask Tutorial
Perfect APK
 
Introduction to Xamarin and Xamarin Forms
Introduction to Xamarin and Xamarin FormsIntroduction to Xamarin and Xamarin Forms
Introduction to Xamarin and Xamarin Forms
Angelo Gino Varrati
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
Android studio 2.0
Android studio 2.0Android studio 2.0
Android studio 2.0
Edouard Marquez
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
Michael Pan
 
Android Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App DevelopersAndroid Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App Developers
Reto Meier
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
Taufan Erfiyanto
 
Bus Tracking Application in Android
Bus Tracking Application in AndroidBus Tracking Application in Android
Bus Tracking Application in Android
Abhishek Singh
 

Viewers also liked (20)

Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add ons
 
Database
DatabaseDatabase
Database
 
Taty
TatyTaty
Taty
 
Rajab Davudov - Android Database
Rajab Davudov - Android DatabaseRajab Davudov - Android Database
Rajab Davudov - Android Database
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
 
Video Streaming: from the native Android player to unconventional devices
Video Streaming: from the native Android player to unconventional devicesVideo Streaming: from the native Android player to unconventional devices
Video Streaming: from the native Android player to unconventional devices
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
 
[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...[Ultracode Munich #4] Short introduction to the new Android build system incl...
[Ultracode Munich #4] Short introduction to the new Android build system incl...
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
 
Xamarin Traditional Approach & Xamarin.Forms
Xamarin Traditional Approach & Xamarin.FormsXamarin Traditional Approach & Xamarin.Forms
Xamarin Traditional Approach & Xamarin.Forms
 
Android AsyncTask Tutorial
Android AsyncTask TutorialAndroid AsyncTask Tutorial
Android AsyncTask Tutorial
 
Introduction to Xamarin and Xamarin Forms
Introduction to Xamarin and Xamarin FormsIntroduction to Xamarin and Xamarin Forms
Introduction to Xamarin and Xamarin Forms
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
 
Android studio 2.0
Android studio 2.0Android studio 2.0
Android studio 2.0
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
 
Android Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App DevelopersAndroid Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App Developers
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
 
Bus Tracking Application in Android
Bus Tracking Application in AndroidBus Tracking Application in Android
Bus Tracking Application in Android
 

Similar to Android session 4-behestee

Android datastorage
Android datastorageAndroid datastorage
Android datastorageKrazy Koder
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
AbdullahMunir32
 
Memory management
Memory managementMemory management
Memory management
Vikash Patel
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
Aakash Ugale
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
AbdullahMunir32
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx
FaezNasir
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
n|u - The Open Security Community
 
MA DHARSH.pptx
MA DHARSH.pptxMA DHARSH.pptx
MA DHARSH.pptx
DharshiniB15
 
Share preference
Share preferenceShare preference
Share preference
SbahatNosheen
 
Android local databases
Android local databasesAndroid local databases
Android local databases
FatimaYousif11
 
Level 4
Level 4Level 4
Level 4
skumartarget
 
Computer Software | Lecture 4D
Computer Software | Lecture 4DComputer Software | Lecture 4D
Computer Software | Lecture 4D
CMDLMS
 
Computer Software - Lecture D
Computer Software - Lecture DComputer Software - Lecture D
Computer Software - Lecture D
CMDLearning
 
Android application development fundamentals
Android application development fundamentalsAndroid application development fundamentals
Android application development fundamentals
indiangarg
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
RyanISI
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applications
TOPS Technologies
 
Analytics with unified file and object
Analytics with unified file and object Analytics with unified file and object
Analytics with unified file and object
Sandeep Patil
 
Bn1 1020 demo android
Bn1 1020 demo  androidBn1 1020 demo  android
Bn1 1020 demo android
conline training
 
Scoped storage in android 10 all you need to know
Scoped storage in android 10  all you need to knowScoped storage in android 10  all you need to know
Scoped storage in android 10 all you need to know
RobertJackson147
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 

Similar to Android session 4-behestee (20)

Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
 
Memory management
Memory managementMemory management
Memory management
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
 
12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx12_Data_Storage_Part_2.pptx
12_Data_Storage_Part_2.pptx
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
 
MA DHARSH.pptx
MA DHARSH.pptxMA DHARSH.pptx
MA DHARSH.pptx
 
Share preference
Share preferenceShare preference
Share preference
 
Android local databases
Android local databasesAndroid local databases
Android local databases
 
Level 4
Level 4Level 4
Level 4
 
Computer Software | Lecture 4D
Computer Software | Lecture 4DComputer Software | Lecture 4D
Computer Software | Lecture 4D
 
Computer Software - Lecture D
Computer Software - Lecture DComputer Software - Lecture D
Computer Software - Lecture D
 
Android application development fundamentals
Android application development fundamentalsAndroid application development fundamentals
Android application development fundamentals
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applications
 
Analytics with unified file and object
Analytics with unified file and object Analytics with unified file and object
Analytics with unified file and object
 
Bn1 1020 demo android
Bn1 1020 demo  androidBn1 1020 demo  android
Bn1 1020 demo android
 
Scoped storage in android 10 all you need to know
Scoped storage in android 10  all you need to knowScoped storage in android 10  all you need to know
Scoped storage in android 10 all you need to know
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 

More from Hussain Behestee

Android session 3-behestee
Android session 3-behesteeAndroid session 3-behestee
Android session 3-behestee
Hussain Behestee
 
Android session 2-behestee
Android session 2-behesteeAndroid session 2-behestee
Android session 2-behestee
Hussain Behestee
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
Hussain Behestee
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1Hussain Behestee
 

More from Hussain Behestee (7)

Android session-1-sajib
Android session-1-sajibAndroid session-1-sajib
Android session-1-sajib
 
Android session-5-sajib
Android session-5-sajibAndroid session-5-sajib
Android session-5-sajib
 
Android session 3-behestee
Android session 3-behesteeAndroid session 3-behestee
Android session 3-behestee
 
Android session 2-behestee
Android session 2-behesteeAndroid session 2-behestee
Android session 2-behestee
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
 
iOS Session-2
iOS Session-2iOS Session-2
iOS Session-2
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

Android session 4-behestee

  • 1. ANDROID TRAINING SESSION – 4 -Hussain KMR Behestee
  • 2. AGENDAS • Shared Preferences • Storages • SQLite Database – SQLite Open Helper • Content Providers – SQLite Programming • Content Providers
  • 3. Shared Preferences • The SharedPreferences class provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. • You can save any primitive data: booleans, floats, ints, longs, and strings. This data will persist across user sessions (even if your application is killed). • use one of two methods: – getSharedPreferences() - Use this if you need multiple preferences files identified by name. – getPreferences() - Use this if you need only one preferences. • Call edit() to get a SharedPreferences.Editor • Add values with methods such as putBoolean() and putString(). • Commit the new values with commit() • To read values - getBoolean() and getString()
  • 4. Internal Storage • You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. • To create and write a private file – Call openFileOutput() with the name of the file and the operating mode. This returns a FileOutputStream – Write to the file with write() – Close the stream with close() • To read a file – Call openFileInput() and pass it the name of the file – Read bytes from the file with read() – Then close the stream with close() • Other useful methods: getFilesDir(), getDir(), deleteFile(), fileList()
  • 5. External Storage – Checking media availability - Before you do any work with the external storage, you should always call getExternalStorageState() to check whether the media is available. – Accessing files on external storage • If you're using API Level 8 or greater, use getExternalFilesDir() to open a File • If you're using API Level 7 or lower, use getExternalStorageDirectory() – You should then write your data in the following directory: • /Android/data/<package_name>/files/ • If the user's device is running API Level 8 or greater and they uninstall your application, this directory and all its contents will be deleted. – Hiding your files from the Media Scanner • Include an empty file named .nomedia in your external files directory
  • 6. External Storage – Saving files that should be shared - These directories lay at the root of the external storage • 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. – Getting Shared Files • In API Level 8 or greater, use getExternalStoragePublicDirectory(), passing it the type of public directory you want, such as DIRECTORY_MUSIC, • If you're using API Level 7 or lower, use getExternalStorageDirectory()
  • 7. SQLite Database – 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. – to create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method. You should use it to Create Table – To Upgrade your database use onUpgrade() method. You should use it to Alter Table
  • 8. Android Content Provider App 1 (Dialer) App 2 (Messaging) App 3 (Custom) App 4 (Custom) Content Provider 1 Data can be shared over different applications Content Provider Basics 1. There are no common storage area that all Android application can access. 2. The only way: to share data across applications: Content Provider 3. Content providers store and retrieve data and make it accessible to all applications. Content Provider 2
  • 9. Android Content Provider Content Provider Basics (Contd.) Android ships with a number of content providers for common data types: 1. Audio 2. Video 3. Images 4. Personal contact information etc Content Provider provides the way to share the data between multiple applications. For example, contact data is used by multiple applications (Dialer, Messaging etc.) and must be stored in Content Provider to have common access. A content provider is a class that implements a standard set of methods to let other applications store and retrieve the type of data that is handled by that content provider. Content Provider data App 1 App 2
  • 10. Android Content Provider Querying Data Content Provide: URI 1. Each content provider exposes a public URI that uniquely identifies its data set. 2. A content provider that controls multiple data sets (multiple tables) exposes a separate URI for each one. 3. All URIs for providers begin with the string "content://". The content: scheme identifies the data as being controlled by a content provider. URI samples: <standard_prefix>://<authority>/<data_path>/<id> For example, to retrieve all the bookmarks stored by our web browsers (in Android): content://browser/bookmarks Similarly, to retrieve all the contacts stored by the Contacts application: content://contacts/people To retrieve a particular contact, you can specify the URI with a specific ID: content://contacts/people/3
  • 11. Android Content Provider Content Provide: URI So we need three pieces of information to query a content provider: 1. The URI that identifies the provider 2. The names of the data fields you want to receive 3. The data types for those fields If we are querying a particular record, you also need the ID for that record. Some more examples: content://media/internal/images URI return the list of all internal images on the device. content://contacts/people/ URI return the list of all contact names on the device. content://contacts/people/45 URI return the single result row, the contact with ID=45.