Archiv für: Github

Binärdaten und ContentProvider

Neulich hat sich bei einem meiner kleinen Freizeitprojekte das Problem ergeben, dass der in der Anwendung verwendete ContentProvider auch größere Binärdaten (genauer Bilder) zur Verfügung stellen sollte. Ein Blick in die Android-SDK brachte auch tatsächlich etwas zu dem Thema zum Vorschein (aus dem Artikel zu ContentProvidern):

If you are exposing byte data that’s too big to put in the table itself — such as a large bitmap file — the field that exposes the data to clients should actually contain a content: URI string. This is the field that gives clients access to the data file. The record should also have another field, named “_data” that lists the exact file path on the device for that file. This field is not intended to be read by the client, but by the ContentResolver. […]

Dieses Feature klang recht interessant, allerdings war mir die Erklärung doch etwas zu lang, um das gleich in das “richtige” Projekt einzubauen. Stattdessen habe ich mich an ein kleines Testprojekt gesetzt, um mir die Zusammenhänge etwas zu verdeutlichen. Damit Andere auch etwas davon haben, gibt es das Projekt jetzt als Open-Source auf github und hier ein paar erklärende Worte.

Weiterlesen

Kategorie Software | Tags |