Professional Documents
Culture Documents
TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Android provides many ways of storing data of an application. One of this way is called
Shared Preferences. Shared Preferences allow you to save and retrieve data in the form of
key,value pair.
In order to use shared preferences, you have to call a method getSharedPreferences() that
returns a SharedPreference instance pointing to the file that contains the values of
preferences.
SharedPreferences sharedpreferences = getSharedPreferences(“pref1”,
Context.MODE_PRIVATE);
The first parameter is the key and the second parameter is the MODE. Apart from private
there are other modes available that are listed below −
1 MODE_APPEND
This will append the new preferences with the already existing preferences
4 MODE_PRIVATE
By setting this mode, the file can only be accessed using calling application
5 MODE_WORLD_READABLE
This mode allow other application to read the preferences
6 MODE_WORLD_WRITEABLE
This mode allow other application to write the preferences
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 1
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Apart from the putString method , there are methods available in the editor class that
allows manipulation of data inside shared preferences. They are listed as follows −
1 clear()
It will remove all values from the editor
2 remove(String key)
It will remove the value whose key has been passed as a parameter
To read or retrieve values from the Shared Preferences file, we need to call methods such
as getInt(), getString(), etc. by providing the key for the value which we want to get like
as shown below.
The download manager is a system service that handles long-running HTTP downloads.
Clients may request that a URI be downloaded to a particular destination file. The
download manager will conduct the download in the background, taking care of HTTP
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 2
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
interactions and retrying downloads after failures or across connectivity changes and
system reboots.
Apps that request downloads through this API should register a broadcast receiver
for ACTION_NOTIFICATION_CLICKED to appropriately handle when the user clicks on a
running download in a notification or from the downloads UI.
Note that the application must have the Manifest.permission.INTERNET permission to use
this class.
In android, External Storage is useful to store the data files publically on the shared
external storage using the FileOutputStream object. After storing the data files on
external storage, we can read the data file from external storage media using
a FileInputStream object.
Following is the code snippet to create and write a public file in the
device Downloads folder.
Following is the code snippet to read data from a file that is in the downloads folder.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 3
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
The database is the most common way of storing and managing data. Sometime before,
databases are handled on server-side or cloud and mobile devices only communicate with
them through the network. However, to make applications more responsive and less
dependent on network connectivity, the trend of offline usage or less dependency on the
network is gaining popularity.
Nowadays, applications keep DB locally or make a copy of DB over the cloud onto local
devices and sync with it once in a day or whenever there is network connectivity.
This will help in faster and responsive applications that are functional even when there is
no or limited internet connectivity.
There are lots of mobile databases coming into the market some of them are listed below
SQLite
Realm DB
ORMLite
Berkeley DB
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 4
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Introducing SQLite
SQLite is a free, open source, public-domain software package that provides a RDBMS
(relational database management system). RDBMS are used to store user-defined
records in large tables. In data storage and management system, a database engine can
process complex query commands that combine data from multiple tables to generate
reports and data summary.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 5
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
1 getColumnCount()
This method return the total number of columns of the table.
2 getColumnIndex(String columnName)
This method returns the index number of a column by specifying the name of the
column
3 getColumnName(int columnIndex)
This method returns the name of the column by specifying the index of the column
4 getColumnNames()
This method returns the array of all the column names of the table.
5 getCount()
This method returns the total number of rows in the cursor
Android application publishing is a process that makes your Android applications available
to users. Infect, publishing is the last phase of the Android application development
process.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 6
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Google has made it relatively easy to publish your Android application so that it can be
quickly distributed to end users. The steps to publishing your Android application
generally involve the following:
2. Generate your own self-signed certificate and digitally sign your application with it.
4. Use the Android Market for hosting and selling your application.
Publishing is the general process that makes your Android applications available to users.
When you publish an Android application you perform two main tasks:
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 7
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Step 2: Select Build and then click on “Generate Signed APK” from Android Studio.
Step 3: Now we would need to fill the details accordingly, and press Next.
Key store path and key store password is needed for generating APK or aab file that is
required to upload on Google play store.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 8
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Step 4: And after that, we will choose the Variant and version according to choice and
requirement. After that, we will press Finish.
Step 5: And then Gradle will complete the execution and generate the APK.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 9
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
After you've created your Google Play developer account, you can create apps and set
them up using Play Console.
After you create your app, you can start setting it up. Your app’s dashboard will guide
you through all the most important steps to get your app available on Google Play.
Google Play uses Android App Bundles to generate and deliver APKs that are optimized
for each device configuration, providing users with more efficient apps. This means you
only need to build, sign, and upload a single app bundle to support optimized APKs for a
wide variety of device configurations. Google Play then manages and serves your app's
distribution APKs for you.
Package names for app files are unique and permanent, so please name them carefully.
Package names can't be deleted or re-used in the future.
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 10
Notes: Mobile Application Development Class: B.Sc. CS. TY,
Unit VI: WORKING WITH INTERNET, DATABASES AND PUBLISHING APPS
Question Sets:
For Three (3) Marks
Prepared By: Mr. D. R. Somwanshi (M.Sc.CS, M.Phil, CS) COCSIT Latur Page 11