Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Am I missing implementation for opening an image from a custom Content Provider?
- private void createTableInspectionImages(SQLiteDatabase db) {
- db.execSQL("CREATE TABLE " + Tables.INSPECTION_IMAGES + " ("
- + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
- + InspectionImageColumns.INSPECTION_ID + " TEXT NOT NULL, "
- + InspectionImageColumns.IMAGE_ID + " TEXT NOT NULL, "
- + InspectionImageColumns.DATA + " TEXT NOT NULL, "
- + "FOREIGN KEY(" + InspectionImageColumns.INSPECTION_ID + ") REFERENCES "+ Tables.INSPECTIONS + "(" + InspectionColumns.INSPECTION_ID + ") ON DELETE CASCADE "
- + ")");
- }
- _ID: 1
- INSPECTION_ID: ffd9bb09-3794-4e73-99ed-8afa7742173a
- IMAGE_ID: content://foo.bar/inspection_images/62ff3ea2-6c2f-4b24-bf34-0e0850152c05
- _DATA: /data/data/foo.bar/files/images/inspections/ffd9bb09-3794-4e73-99ed-8afa7742173a/62ff3ea2-6c2f-4b24-bf34-0e0850152c05.jpg
- @Override
- public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
- if(!"r".equals(mode.toLowerCase())) {
- throw new FileNotFoundException("Unsupported mode, " + mode + ", for uri: " + uri);
- }
- return openFileHelper(uri, mode);
- }
- Uri imageUri = Uri.parse(c.getString(c.getColumnIndex(InspectionImages.IMAGE_ID)));
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_VIEW);
- intent.setDataAndType(imageUri, "image/*");
Add Comment
Please, Sign In to add comment