Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android content providers interview questions and answers

1
How to share data between two applications?
  1. use file
  2. use sqlite database
  3. use content provider
  4. use content resolver
Show Answer
Share Facebook gmail Twitter
2
What is the difference between ContentValues and Cursor, in SQLite?
  1. ContentValues is a name value pair, used to get the values from database tables. ContentValues object will be returned from SQLiteDataBase objects query() function. Cursor is a temporary buffer area which will be passed to SQLiteDataBase insert() and update() functions to update table rows.
  2. ContentValues is a temporary buffer, used to insert or update values into database tables. ContentValues object will be passed to SQLiteDataBase objects insert() and update() functions. Cursor is a name value pair object which stores results from a SQLiteDataBase query.
  3. ContentValues is a temporary buffer, used to get the values from database tables. ContentValues object will be returned from SQLiteDataBase objects query() function. Cursor is a name-value pair which will be passed to SQLiteDataBase insert() and update() functions to update table rows.
  4. ContentValues is a name value pair, used to insert or update values into database tables. ContentValues object will be passed to SQLiteDataBase objects insert() and update() functions. Cursor is a temporary buffer area which stores results from a SQLiteDataBase query.
Show Answer
Share Facebook gmail Twitter
3
To upgrade SQLite database of android application, can I pass lesser version number than previous database version?
  1. Helper class will assume that we will always pass version numbers in incremental order for upgrading.
  2. Yes, we can pass.
  3. we don't need to pass any value, system will automatically generate higher version number for next version.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
4
Is it OK to call getWritableDataBase() from the main UI Thread?
  1. Yes it can be.
  2. getWritableDataBase() should not be called on any thread.
  3. it depends on the programming requirement. If programmer want, then yes it can be called on either main or background thread.
  4. No. because if it takes too much of time to create all the tables, then it may interrupt main thread and user experience will get disturbed.
Show Answer
Share Facebook gmail Twitter
5
Will calling helper.getWritableDatabase() always calls onCreate() of Helper class?
  1. It will call helper class onCreate() function only if database is created for the first time.
  2. It will call helper class onCreate() function every time.
  3. It will call helper class onCreate() function every time when ever user starts that application.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
6
I want to access data of outside application in my application. Now do I need to implement content providers in my application or outside application has to implement it?
  1. you have to use binder services
  2. use binder services with content provider in your application
  3. the other application which is sharing data with your application has to implement content provider
  4. your application has to implement content provider
Show Answer
Share Facebook gmail Twitter
7
What is the life cycle of a content provider?
  1. All the content providers will be created (onCreate()) after phone has booted first time.
  2. A content provider's onCreate() function will be called when first time if some client calls providers functions using content resolver.
  3. A content provider's onCreate() function will be called every time if some client calls providers functions using content resolver.
  4. none
Show Answer
Share Facebook gmail Twitter
8
What is the purpose of SQLiteOpenHelper?
  1. A helper class to manage database creation,upgrading and version management with out loosing state of the previous data.
  2. A helper class to manage database creation,version management, and inserting/modifying/deleting/updating table data with out loosing state of the previous data.
  3. A helper class to insert/update/delete data into tables with loosing state of the previous data.
  4. all of the above.
Show Answer
Share Facebook gmail Twitter
9
How to upgrade SQLite database of an android application, before uploading the new version into play store?
  1. Pass new version number for database to SQLiteOpenHelper() function. Then update the database in onUpdate of SQLiteOpenHelper class.
  2. Pass new version number for database to getWriteableDataBase() function. Then update the database in onUpdate of SQLiteOpenHelper class.
  3. Pass new version number for database to SQLiteOpenHelper() function. Then update the database in onCreate() of SQLiteOpenHelper class.
  4. Release new application with latest data base, don't modify old application, it will corrupt existing application.
Show Answer
Share Facebook gmail Twitter
10
Can one application access other application's database directly?
  1. yes, it is possible
  2. no, it is impossible
  3. option 2 is right because, sqliteDB will be stored in internal memory app always. so other apps cannot access it.
  4. Option 2 is wrong, because even if db tables are stored in internal memory, using Content Provider one can access database.
Show Answer
Share Facebook gmail Twitter
11
How to start a content provider using an intent?
  1. possible. Content provider is also a component of android, so we can use intent to start it.
  2. not possible. Using intent you can't trigger a content provider.
  3. option 2 is correct because, we use content resolver to communicate with content provider
  4. none
Show Answer
Share Facebook gmail Twitter
12
What is the use of content provider? Will it support shared preferences?
  1. It is used to store SQLiteData, right now shared preferences are not supported by ContentProvider.
  2. It is used to share an application's data with out side world. Right now there is no support for shared preferences.
  3. It is used to communicate with content resolver.
  4. it will data content. every app will contain one content provider by default.
Show Answer
Share Facebook gmail Twitter
13
What is the difference between contentprovider and contentresolver?
  1. they are not at all related with each other
  2. content provider is used to share private data with other applications, where as content-resolver communicates from client end with content provider.
  3. content resolver is used to share private data with other applications, where as content-provider communicates from client end with content resolver.
  4. content provider is used to store private data, where as content-resolver communicates from client end with content provider.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
15
How to get contact phone number from contacts application's content provider?
  1. Use ContactsContract.Contacts.URI and request through content resolver
  2. Use Contacts.Phone.URI and request through content resolver
  3. Use ContactsContract.Contacts.URI and CommonDataKinds.Phone.CONTENT_URI, then request it through content resolver
  4. none
Show Answer
Share Facebook gmail Twitter
16
Where does the SQLite database of an android application get stored in memory?
  1. apps internal memory
  2. on sd card
  3. on network server
  4. by default it is stored in internal memory, but it is also possible to store it in sd card also.
Show Answer
Share Facebook gmail Twitter
17
How to store heavy structured data in android application?
  1. files
  2. sqlite
  3. preferences
  4. dont store in sqlite, because it is not private to application
Show Answer
Share Facebook gmail Twitter
18
Why we have to create and upgrade database only in SQLiteOpenHelper?
  1. It is mandatory to upgrade in SQLiteOpenHelper only, else SQLite will generate compile time error, this is due to security reasons.
  2. Because SQLiteOpenHelper will make sure that database is always in sensible state. Also it manages the threads if more than one thread is trying to touch DB.
  3. None of the above.
  4. all of the above.
Show Answer
Share Facebook gmail Twitter
19
How to upgrade database tables?
  1. Pass different version number in incremental order, and put all upgrading code in onUpgrade() of helper class.
  2. Pass different version number in incremental order, and put all upgrading code in onCreate() of helper class.
  3. Pass different version number in any order, and put all upgrading code in onUpgrade() of helper class.
  4. Pass different version number in decremental order, and put all upgrading code in onUpgrade() of helper class.
Show Answer
Share Facebook gmail Twitter
20
Creating Helper object, or getting SQLiteDatabase object, which one is asynchronous (takes more time?).
  1. Creating helper object takes more time.
  2. We can't predict, some times creating helper object takes time and some times getting database object may take time. so we can't guess which is asynchronous.
  3. Creating helper object is synchronous which returns immediately, where as getWritableDatabase may take time when you are creating db for the first time. So it may take more time (asynchronous) for the first time or when we are upgrading the database.
  4. creating and getting sqlitedatabase object is asynchronous some times, but we can't guess when it will be asynchronous.
Show Answer
Share Facebook gmail Twitter
Read more papers :