-
public class AttachmentsDatabaseClass for simple interaction with database containing attachemnts.
When the first read or write requests are made, database will be 'opened' and later should be close manually via close method. If database has been 'closed' but new read/write request is made then it will be opened again and will have to be closed again.
Simple interactions with database are fast and can be done on main thread. However, there are exceptions. For example, if there is a massive data to write or database needs to change it's structure (onUpdate/onDowngrade/onCreate) it could block caller thread for some time. So it is recommended to call all read/write methods from worker thread.
See great article on Android DB: https://www.grokkingandroid.com/sqlite-in-android/
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAttachmentsDatabase.Entrypublic classAttachmentsDatabase.AttachmentsDbHelper
-
Field Summary
Fields Modifier and Type Field Description public final static intCURRENT_VERSIONpublic final static StringNAME
-
Constructor Summary
Constructors Constructor Description AttachmentsDatabase(Context context)Do not forget to call close once you are done with this DB.See class description.
-
Method Summary
Modifier and Type Method Description longinsert(Array<MessageAttachmentInternal> attachmentsArray)Map<Long, MessageAttachmentInternal>getAllAttachments()MessageAttachmentInternalgetAttachment(String attachmentId)voidclose()Call to close all open database object. -
-
Method Detail
-
insert
@WorkerThread() long insert(Array<MessageAttachmentInternal> attachmentsArray)
-
getAllAttachments
@WorkerThread() Map<Long, MessageAttachmentInternal> getAllAttachments()
-
getAttachment
@WorkerThread() MessageAttachmentInternal getAttachment(String attachmentId)
-
close
void close()
Call to close all open database object.
-
-
-
-