hasanghaforian hasanghaforian - 4 days ago 4
Android Question

how to get ParcelFileDescriptor for file content?

I use eclipse-indigo and

android 2.3.3_r1
and I download a string from a server in network.It is the content of
docx
file.

Can I receive a
ParcelFileDescritor
from it? I guess that
MemoryFile
can help me, because I saw
getParcelFileDescriptor()
method for it here and here, but when I'm writing my code in eclipse, I cannot find method
getParcelFileDescriptor()
in class
android.os.MemoryFile
.

Finally this is my question: is it possible without using socket()?

Answer

getParcelFileDescriptor() is a package private method,so I could not found it in my class(that is in another package).I tried to access it by reflection but finally I understand that it return a suitable ParcelFileDescritor,if and only if,we create our MemoryFile as a reference to an existing memory file and in this case we want File descriptor from that existing memory file.So this method can not help us.Also it seems that in later versions of Android,this method is completely ignored and removed from class.

Comments