@@ -45,18 +45,29 @@ public class SQLiteContentHelper {
45
45
* value of column 0 is NULL, or if there is an error creating the
46
46
* asset file descriptor.
47
47
*/
48
- public static MemoryFile getBlobColumnAsAssetFile (SQLiteDatabase db , String sql ,
49
- String [] selectionArgs ) throws FileNotFoundException {
50
- try {
51
- MemoryFile file = simpleQueryForBlobMemoryFile (db , sql , selectionArgs );
52
- if (file == null ) {
53
- throw new FileNotFoundException ("No results." );
54
- }
55
- return file ;
56
- } catch (IOException ex ) {
57
- throw new FileNotFoundException (ex .toString ());
58
- }
59
- }
48
+ public static AssetFileDescriptor getBlobColumnAsAssetFile (SQLiteDatabase db , String sql ,
49
+ String [] selectionArgs ) throws FileNotFoundException {
50
+ android .os .ParcelFileDescriptor fd = null ;
51
+
52
+ try {
53
+ MemoryFile file = simpleQueryForBlobMemoryFile (db , sql , selectionArgs );
54
+ if (file == null ) {
55
+ throw new FileNotFoundException ("No results." );
56
+ }
57
+ Class c = file .getClass ();
58
+ try {
59
+ java .lang .reflect .Method m = c .getDeclaredMethod ("getParcelFileDescriptor" );
60
+ m .setAccessible (true );
61
+ fd = (android .os .ParcelFileDescriptor )m .invoke (file );
62
+ } catch (Exception e ) {
63
+ android .util .Log .i ("SQLiteContentHelper" , "SQLiteCursor.java: " + e );
64
+ }
65
+ AssetFileDescriptor afd = new AssetFileDescriptor (fd , 0 , file .length ());
66
+ return afd ;
67
+ } catch (IOException ex ) {
68
+ throw new FileNotFoundException (ex .toString ());
69
+ }
70
+ }
60
71
61
72
/**
62
73
* Runs an SQLite query and returns a MemoryFile for the
@@ -84,6 +95,7 @@ private static MemoryFile simpleQueryForBlobMemoryFile(SQLiteDatabase db, String
84
95
}
85
96
MemoryFile file = new MemoryFile (null , bytes .length );
86
97
file .writeBytes (bytes , 0 , 0 , bytes .length );
98
+
87
99
// file.deactivate();
88
100
return file ;
89
101
} finally {
0 commit comments