cant read file from data/data/pkg/files/...

by Komal » Mon, 30 Mar 2009 10:29:41 GMT


Sponsored Links
 Hi,
I am saving an image using openFileOutput and now i want to use this
image in my java script file.
I am saving image using this code :

Bitmap b=DownloadImage(imageUrl);
FileOutputStream fos = mcontx.openFileOutput(imageName,
Context.MODE_WORLD_WRITEABLE)                    b.compress(CompressFormat.JPEG,
75, fos);
fos.flush();
fos.close();

It successfully write the image , i can see it in the file explorer of
emulator.
and   i can display that image using openFileInput in image view.
But,,
There is another activity where i am using webview to call javascript.
i want to read that image in my javascript.my javascript code is ::

*****************************************************************************************************
<html xmlns=" http://www.w3.org/1999/xhtml" ;>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title</title>
</head>
<script language="javascript">
            /* This function is invoked by the activity */
               function display() {



                    var path="data/data/com.android.mypkg/
files/"+window.mypage.getImageName();
                    document.getElementById("img").src=path;



                }

</script>

<body onLoad="window.mypage.callAndroid()">
<!-- Calls into the javascript interface for the activity -->
        <img id="img" src="" />

        <p>
                <b> <script type="text/javascript">
                        var hl=window.mypage.getHeadline();
                        document.write(hl);
                        </script>
                </b>
        </p>
</body>
</html>

**********************************************************************************************
it is not displaying an image.
can i read file from data/data/pkg/files/... directly like this?
Please help me
Thanx
komal


--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Komal » Tue, 31 Mar 2009 07:16:53 GMT


 Hello
please help me!!!
Thank you



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


cant read file from data/data/pkg/files/...

by Mike Collins » Tue, 31 Mar 2009 07:40:37 GMT


 If my understanding is correct, in general you can't because of
security.
Stuff under /data/data/package/... is protected from any code except
the
package itself.

  mike





--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Komal » Tue, 31 Mar 2009 08:19:45 GMT


 i Mike,
Thanks for your reply.

My xhtml file is under assets folder,it is in the app, then why cant i
use it?

and i can use all images saved in assets in the xhtml page.
but i cant save image at runtime in the assets folder using
file:///android_asset/filename.jpg
I manually save .jpg file under assets and use it in the xhtml file,
it displays an image.


On Mar 31, 10:40am, Mike Collins <mike.d.coll...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Mark Murphy » Tue, 31 Mar 2009 08:34:22 GMT


 


Assets are packaged inside the APK and are read-only.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Komal » Tue, 31 Mar 2009 09:32:25 GMT


 Thanx mark,

Can i read from data/data/pkg/files/filenm in java script/html page?

Thanx komal






--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Mark Murphy » Tue, 31 Mar 2009 09:33:10 GMT


 


I don't know. I have never tried it.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by Komal » Tue, 31 Mar 2009 11:27:05 GMT


 Hi,
if somebody can solve my doubt ,please help me!!!

Thanks in advance!!!





--~--~---------~--~----~------------~-------~--~----~



cant read file from data/data/pkg/files/...

by xiao dao » Tue, 14 Apr 2009 00:58:50 GMT


 Hi,
   Please change this line code .

FileOutputStream fos = mcontx.openFileOutput(imageName,
Context.MODE_WORLD_READABLE)




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. error compiling source under Ubuntu

development/emulator/qtools/trace_reader.cpp:736: warning: deprecated
conversion from string constant to har*development/emulator/qtools/trace_reader.cpp:741: warning: deprecated
conversion from string constant to har*development/emulator/qtools/trace_reader.cpp: In function har*
ExtractDexPathFromMmap(const char*)
development/emulator/qtools/trace_reader.cpp:1012: error: invalid
conversion from onst char*to har*development/emulator/qtools/trace_reader.cpp:1013: error: conflicting
declaration onst char* enddevelopment/emulator/qtools/trace_reader.cpp:1012: error: ndhas a
previous declaration as har* enddevelopment/emulator/qtools/trace_reader.cpp:1016: error: invalid
conversion from onst char*to har*development/emulator/qtools/trace_reader.cpp: In member function oid
TraceReaderBase::Open(char*)
development/emulator/qtools/trace_reader.cpp:736: warning: deprecated
conversion from string constant to har*development/emulator/qtools/trace_reader.cpp:741: warning: deprecated
conversion from string constant to har*development/emulator/qtools/trace_reader.cpp: In member function oid
TraceReaderBase::Open(char*)
development/emulator/qtools/trace_reader.cpp:736: warning: deprecated
conversion from string constant to har*development/emulator/qtools/trace_reader.cpp:741: warning: deprecated
conversion from string constant to har*make: *** [out/host/linux-x86/obj/EXECUTABLES/bbprof_intermediates/
trace_reader.o] Error 1
make: *** Waiting for unfinished jobs....
development/emulator/qtools/trace_reader.cpp: In function har*
ExtractDexPathFromMmap(const char*)
development/emulator/qtools/trace_reader.cpp:1012: error: invalid
conversion from onst char*to har*development/emulator/qtools/trace_reader.cpp:1013: error: conflicting
declaration onst char* enddevelopment/emulator/qtools/trace_reader.cpp:1012: error: ndhas a
previous declaration as har* enddevelopment/emulator/qtools/trace_reader.cpp:1016: error: invalid
conversion from onst char*to har*development/emulator/qtools/trace_reader.cpp: In function har*
ExtractDexPathFromMmap(const char*)
development/emulator/qtools/trace_reader.cpp:1012: error: invalid
conversion from onst char*to har*development/emulator/qtools/trace_reader.cpp:1013: error: conflicting
declaration onst char* enddevelopment/emulator/qtools/trace_reader.cpp:1012: error: ndhas a
previous declaration as har* enddevelopment/emulator/qtools/trace_reader.cpp:1016: error: invalid
conversion from onst char*to har*make: *** [out/host/linux-x86/obj/EXECUTABLES/bb_dump_intermediates/
trace_reader.o] Error 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/bb2sym_intermediates/
trace_reader.o] Error 1


these are the errors i get

any ideas?

-- 

2. Help with Getting Data from web server

Hi,

I am relatively new to android and i would like to know if it is
possible of getting data using http post and get to and from the web
server.
And also if i do not have access to the parameters to the web server,
how would i go about getting it.

Thank you.

-- 

3. Android: ListAdapter populating image (icon) source

4. Android to Windows ICS (Internet Connection Sharing) via WiFi

5. Success in Google Calendar but not > 1.5

6. Is Browsing While Calling Impossible? Why?

7. option to disable Trace-Jit for interested application on non-rooted phone