[Solved] plz help if anyone know it

Put your problem here if it does not fit any of the other categories.

[Solved] plz help if anyone know it

Postby soniya » Fri Feb 08, 2008 11:05 am

i m use all data in project for text files.......that text file will be parse and use in project......
that file we put in folder ....
in project where we put that folder.......
for example i put
in res/raw/data/file.txt but i could we read that file where we put it??? :(
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Postby plusminus » Fri Feb 08, 2008 3:33 pm

Hello soniya,

the Resource-Class provides a openRarResource-Function that returns an InputStream:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. InputStream is = this.getResources().openRawResource(R.raw.myfile);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I think this is what you were searching for.

Let us know if it helped you :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby soniya » Sat Feb 09, 2008 7:31 am

i try in raw folder that way plz see attach pic....
when i use
inputstream =this.getResources().openRawResource(R.raw.list);

but it show "R.raw.list cannot resolved" how to access that file??
Attachments
123.JPG
123.JPG (7.83 KiB) Viewed 1094 times
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Sat Feb 09, 2008 11:45 am

Hello soniya,

unfortunately no subfolders are supported (yet :?:).
It works only with "top-level"-files like "/res/raw/xyz.txt".
If you create a subfolder its content is not listed in the R.java and therefore you cannot refer to it.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby soniya » Sat Feb 09, 2008 1:51 pm

i need that file in my application where we put it??? :(
actually i have folder it have some subfolder and txt file....that folder we will use in appliction....i want access all folder and file .......
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Sat Feb 09, 2008 2:40 pm

Hello soniya,

I think I am repeating myself. Subfolders within the main-resources-folders are not possible :!:
Perhaps Google will add such a possibility within the next SDK updates.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby soniya » Mon Feb 11, 2008 8:58 am

if we use zip and jar file....then is it possible???
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby plusminus » Mon Feb 11, 2008 3:23 pm

Hello soniya,

yes you could use a zip-file, as it can contain a folder structure inside.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby soniya » Tue Feb 12, 2008 7:17 am

thanks for reply it's working.....
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Postby Jesmiatka » Tue Feb 12, 2008 9:44 am

So just to sum it up:

You wanted to read a file that was in a special directory structure, but since it wasn't possible in Android to read sub-folders in the resource map (yet?) you made a zip file. Now you read the zip because it is possible to use the specified directory structure?
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests