Guest User

Untitled

a guest
Aug 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Am I missing implementation for opening an image from a custom Content Provider?
  2. private void createTableInspectionImages(SQLiteDatabase db) {
  3. db.execSQL("CREATE TABLE " + Tables.INSPECTION_IMAGES + " ("
  4. + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
  5. + InspectionImageColumns.INSPECTION_ID + " TEXT NOT NULL, "
  6. + InspectionImageColumns.IMAGE_ID + " TEXT NOT NULL, "
  7. + InspectionImageColumns.DATA + " TEXT NOT NULL, "
  8. + "FOREIGN KEY(" + InspectionImageColumns.INSPECTION_ID + ") REFERENCES "+ Tables.INSPECTIONS + "(" + InspectionColumns.INSPECTION_ID + ") ON DELETE CASCADE "
  9. + ")");
  10. }
  11.  
  12. _ID: 1
  13. INSPECTION_ID: ffd9bb09-3794-4e73-99ed-8afa7742173a
  14. IMAGE_ID: content://foo.bar/inspection_images/62ff3ea2-6c2f-4b24-bf34-0e0850152c05
  15. _DATA: /data/data/foo.bar/files/images/inspections/ffd9bb09-3794-4e73-99ed-8afa7742173a/62ff3ea2-6c2f-4b24-bf34-0e0850152c05.jpg
  16.  
  17. @Override
  18. public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
  19. if(!"r".equals(mode.toLowerCase())) {
  20. throw new FileNotFoundException("Unsupported mode, " + mode + ", for uri: " + uri);
  21. }
  22. return openFileHelper(uri, mode);
  23. }
  24.  
  25. Uri imageUri = Uri.parse(c.getString(c.getColumnIndex(InspectionImages.IMAGE_ID)));
  26. Intent intent = new Intent();
  27. intent.setAction(Intent.ACTION_VIEW);
  28. intent.setDataAndType(imageUri, "image/*");
Add Comment
Please, Sign In to add comment