Answer: B use getReadableDatabase
Description: Query() means reading the data. so getReadableDatabase() is sufficient.
If you are doing too many operations on database like querying, updating frequently in some random order, then it doesn't really make any sense in using getReadabledatabase as it can be used only to read the values.
Based on your app requirement you can judge the usage. If you are only reading the values constantly then you can go for getreadabledatabase.
Answer: B First time when the application containing that content provider is loaded into the memory, it will be called.
Description: onCreate() will be called when the application containing the content provider is loaded into the memory for the first time.
Answer: B To share data between Android applications.
Description: If you want to share the data of one application with the application then use content provider.
Note: We can start an Activity, a service, and a broadcast receiver by using intents. But you can't start or communicate with a content provider by using intents. If you want to communicate with content provider then you have to use content resolver.
1.content provider, and resolver will handle IPC(Inter process communication) mechanism when sharing data between 2 applications.
2.content provider has the capability to handle multiple threads, when queries are coming from multiple resolvers.
Answer: A Content Provider
Description: If you want to share the data of one application with the application then use content provider.
Answer: A It will move the cursor to point to next row if it is available, else it returns false.
Description: It will move the cursor to point to next row if it is available, else it returns false.
Answer: B First we have to check if cursor is valid or not, by comparing with null.
Description: First we have to check if cursor is valid or not by cross checking it with null.
Answer: C It will leak the memory. Once you are done with database we have to close it, because it will be cached into memory when we open it and eat up memory space.
Description:
Answer: D getWritableDatabase() may take lot of time to create and update tables, so its better to differ this call to later point of time. because if we put here, then application loading time will be increased and may irritate user.
Description: getWritableDatabase() may take lot of time to create and update tables, so its better to differ this call to later point of time. because if we put this call in onCreate(), then application loading time will be increased and may irritate the user.
Answer: A onCreate, insert, update, delete, query, getType.
Description: onCreate, insert, update, delete, query, getType are the mandatory functions to be implemented in Content Provider.
Answer: C This is main key or hint to Android on which content provider the query has to be redirected to. When clients pass URI, it will have authorities in it which should match with authorities part of provider tag.
Description: Authorities is main key or hint to Android on which content provider the query has to be redirected to. When clients pass URI, it will have authorities in it which should match with authorities part of provider tag.
Answer: B i & ii
Description: If you want to share the data of one application with the application then use content provider.
Only content resolver can communicate with content provider, from client application.
Note: We can start an Activity, a service, and a broadcast receiver by using intents. But you can't start or communicate with a content provider by using intents. If you want to communicate with content provider then you have to use content resolver.
1.content provider, and resolver will handle IPC(Inter process communication) mechanism when sharing data between 2 applications.
2.content provider has the capability to handle multiple threads, when queries are coming from multiple resolvers.
Answer: B i & ii
Description: It is used for conversion logic or mapping logic from Uris to tables.It is similar to DNS, which converts URLs to IP addresses.
Note : Just like how we use URLs to connect to servers in the internet (eg: http://google.com for google server) similarly, in android if any application wants to access the data hold by other applications which is shared via content provider, the client application has to access it via URI (Uniform resource identifier). URI's looks exactly like an URL.
When client application access our database tables using URI, UriMatcher will map that URI to appropriate table.
Answer: C i, ii, & iii
Description: 1.Create a separate interface file, which is accessible to out side world and put table URIs in that file.
2.Along with URIs we have to mention column names of all the tables, which we are exposing with URIs.
3.Then we have to document in interface file about what is the data type of each column.
Answer: C ii & iii
Description: DB is used to create tables private to application. You can access SQLite Database with in the application directly. Other applications can't directly touch the SQLite Database of a given application.If you want to share your database with other applications then use Content provider.
Content provider is used to share the data with other applications.
Answer: C ii & iii
Description: To share data with other applications, data can be stored internally by using files, or databases, or through some network servers. Right now there is no support for SharedPreferences.
Answer: B it will be available only from onCreate() of content provider.
Description: context will be available only from onCreate() of content provider.
Answer: D both option 1 and 2 are right.
Description: use getcontext() in oncreate() or use getApplicationContext().
Answer: B It is getting all rows of contacts table, and fetching contact name from first row.
Description: we are getting all rows of contacts table into a cursor, and fetching contact name from first row.