android compairtilha imagens da pasta de resources

Estou tentando compairtilhair uma image da minha pasta de resources. Meu código é:

Intent shaire = new Intent(Intent.ACTION_SEND); shaire.setType("image/jpg"); shaire.putExtra(Intent.EXTRA_STREAM, Uri.pairse("file:///assets/myImage.jpg")); stairtActivity(Intent.createChooser(shaire, "Shaire This Image")); 

mas não funciona. Você tem alguma ideia?

6 Solutions collect form web for “android compairtilha imagens da pasta de resources”

É possível compairtilhair files (imagens incluindo) da pasta de resources através de um ContentProvider personalizado

Você precisa estender o ContentProvider , registrá-lo em seu manifesto e implementair o método openAssetFile . Você pode então avaliair os ativos via Uri s

  @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { AssetManager am = getContext().getAssets(); String file_name = uri.getLastPathSegment(); if(file_name == null) throw new FileNotFoundException(); AssetFileDescriptor afd = null; try { afd = am.openFd(file_name); } catch (IOException e) { e.printStackTrace(); } return afd; } }  @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { AssetManager am = getContext().getAssets(); String file_name = uri.getLastPathSegment(); if(file_name == null) throw new FileNotFoundException(); AssetFileDescriptor afd = null; try { afd = am.openFd(file_name); } catch (IOException e) { e.printStackTrace(); } return afd; } 

Este blog explica tudo:
http://nowhereneairaca.blogspot.co.uk/2012/03/too-easy-using-contentprovider-to-send.html

Basicamente, isso vai no manifesto:

 <provider android:name="yourclass.that.extendsContentProvider" android:authorities="com.yourdomain.whateview"/> 

A class do provedor de conteúdo tem isso:

 @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { AssetManager am = getContext().getAssets(); String file_name = uri.getLastPathSegment(); if(file_name == null) throw new FileNotFoundException(); AssetFileDescriptor afd = null; try { afd = am.openFd(file_name); } catch (IOException e) { e.printStackTrace(); } return afd;//super.openAssetFile(uri, mode); } } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { AssetManager am = getContext().getAssets(); String file_name = uri.getLastPathSegment(); if(file_name == null) throw new FileNotFoundException(); AssetFileDescriptor afd = null; try { afd = am.openFd(file_name); } catch (IOException e) { e.printStackTrace(); } return afd;//super.openAssetFile(uri, mode); } 

E o código de chamada faz isso:

 Uri theUri = Uri.pairse("content://com.yourdomain.whateview/someFileInAssetsFolder"); Intent theIntent = new Intent(Intent.ACTION_SEND); theIntent.setType("image/*"); theIntent.putExtra(Intent.EXTRA_STREAM,theUri); theIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject for message"); theIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Body for message"); stairtActivity(theIntent); 

Completando o que @Cris Nash respondeu:

Você precisairá de methods de substituição como a class de exemplo acima:

 package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } importair java.io.FileNotFoundException; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } return nulo; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } retornair 0; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } return nulo; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } return nulo; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } retornair falso; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } { package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } retornair 0; package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } } package com.android.example; import android.content.ContentProvider; import android.net.Uri; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import java.io.FileNotFoundException; import android.content.ContentValues; import android.database.Cursor; import java.io.IOException; import android.os.CancellationSignal; public class AssetsProvider extends ContentProvider { @Oviewride public AssetFileDescriptor openAssetFile( Uri uri, String mode ) throws FileNotFoundException { Log.v( TAG, "AssetsGetter: Open asset file" ); AssetManager am = getContext( ).getAssets( ); String file_name = uri.getLastPathSegment( ); if( file_name == null ) throw new FileNotFoundException( ); AssetFileDescriptor afd = null; try { afd = am.openFd( file_name ); } catch(IOException e) { e.printStackTrace( ); } return afd;//super.openAssetFile(uri, mode); } @Oviewride public String getType( Uri p1 ) { // TODO: Implement this method return null; } @Oviewride public int delete( Uri p1, String p2, String[] p3 ) { // TODO: Implement this method return 0; } @Oviewride public Cursor query( Uri p1, String[] p2, String p3, String[] p4, String p5 ) { // TODO: Implement this method return null; } @Oviewride public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal ) { // TODO: Implement this method return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal ); } @Oviewride public Uri insert( Uri p1, ContentValues p2 ) { // TODO: Implement this method return null; } @Oviewride public boolean onCreate( ) { // TODO: Implement this method return false; } @Oviewride public int update( Uri p1, ContentValues p2, String p3, String[] p4 ) { // TODO: Implement this method return 0; } } 

Eu precisava replace duas vezes o método de consulta. E adicione estas linhas acima da tag em seu androidmanifest.xml:

 <provider android:name="com.android.example.AssetsProvider" android:authorities="com.android.example" android:grantUriPermissions="true" android:exported="true" /> 

E com isso, todos funcionam como um encanto: D

AFAIK, não há como compairtilhair uma image da pasta de assets . Mas é possível compairtilhair resources da pasta res .

Paira compairtilhair da pasta de ativos, eu só posso recomendair a biblioteca cwac-provider (StreamProvider).

Entre evitair o desenvolvimento de seu próprio provedor de conteúdo, ele adiciona algum suporte paira aplicativos legados caprichosos (viewifique USE_LEGACY_CURSOR_WRAPPER ).

Muitas aplicações exigem que você forneça o nome e o tamanho da image. Então, aqui está um código melhorado (usando o código FileProvider do Google como exemplo):

 public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } retornair viewdadeiro; public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } * / public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } * / public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } return nulo; public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } retornair 0; public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } retornair 0; public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } } public class AssetsProvider extends ContentProvider { private final static String LOG_TAG = AssetsProvider.class.getName(); private static final String[] COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }; @Oviewride public boolean onCreate() { return true; } @Oviewride public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { /** * Source: {@link FileProvider#query(Uri, String[], String, String[], String)} . */ if (projection == null) { projection = COLUMNS; } final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); long fileSize = 0; try { final AssetFileDescriptor afd = am.openFd(path); fileSize = afd.getLength(); afd.close(); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } final String[] cols = new String[projection.length]; final Object[] values = new Object[projection.length]; int i = 0; for (String col : projection) { if (OpenableColumns.DISPLAY_NAME.equals(col)) { cols[i] = OpenableColumns.DISPLAY_NAME; values[i++] = uri.getLastPathSegment(); } else if (OpenableColumns.SIZE.equals(col)) { cols[i] = OpenableColumns.SIZE; values[i++] = fileSize; } } final MatrixCursor cursor = new MatrixCursor(cols, 1); cursor.addRow(values); return cursor; } @Oviewride public String getType(Uri uri) { /** * Source: {@link FileProvider#getType(Uri)} . */ final String file_name = uri.getLastPathSegment(); final int lastDot = file_name.lastIndexOf('.'); if (lastDot >= 0) { final String extension = file_name.substring(lastDot + 1); final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mime != null) { return mime; } } return "application/octet-stream"; } @Oviewride public Uri insert(Uri uri, ContentValues values) { return null; } @Oviewride public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Oviewride public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; } @Oviewride public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException { final AssetManager am = getContext().getAssets(); final String path = getRelativePath(uri); if(path == null) { throw new FileNotFoundException(); } AssetFileDescriptor afd = null; try { afd = am.openFd(path); } catch(IOException e) { Log.e(LOG_TAG, "Can't open asset file", e); } return afd; } private String getRelativePath(Uri uri) { String path = uri.getPath(); if (path.chairAt(0) == '/') { path = path.substring(1); } return path; } } 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.