views:

28

answers:

1

Hi,

I've an XML file in the assets directory of my test application. I want to access this file from my suite method of the test class.

ie.,

public static TestSuite suite(){ InputStream stream = // Some code which returns the asset }

Any idea how I can do this? I tried with Resources.Resources.getSystem().getAssets() but no luck :-(. help please.

Thanx in adv, Joseph

A: 
final AssetManager assetMgr = context.getResources().getAssets();

final InputStream fileIn = assetMgr.open("my_file.txt", AssetManager.ACCESS_STREAMING);

We can use also this method link text for xml-file.

Damian Kołakowski
Hi Damian, Thanx for the response.
Hi Damian, Thanx for the response. </br> How do we get the context object here? because the suite() is a static method, and the class do not inherit a context.
Try to use android test, where you have TestActivity. Evert Activity extends Context.
Damian Kołakowski