Resources getAssets - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Resources getAssets method.

This code example shows how to use the following methods:getAssets, getConfiguration, getDisplayMetrics
public class XWalkMixedResources extends Resources {
 
    private Resources mExtend;
 
    XWalkMixedResources(Resources base, Resources extend) {
        super(base.getAssets(), base.getDisplayMetrics(),
                base.getConfiguration());
        mExtend = extend;
    } 
 
    @Override 
    public CharSequence getText(int id) throws NotFoundException {
        try { 
            return mExtend.getText(id);
        } catch (NotFoundException e) {
            return super.getText(id);
        } 
    } 
 
    @Override 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
public class AssetUtil { 
 
    /** Read a properties file from /assets.  Returns null if it does not exist. */ 
    public static Properties getProperties(String name, Context context) {
        Resources resources = context.getResources();
        AssetManager assetManager = resources.getAssets();
 
        // Read from the /assets directory 
        try { 
            InputStream inputStream = assetManager.open(name);
            Properties properties = new Properties();
            properties.load(inputStream);
            return properties;
        } catch (IOException e) {
            Log.e("Gibberbot", "exception reading properties", e);
            return null; 
        } 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
	public ServerProperties() { 
		 
 
		// Read from the /assets directory 
		try { 
			AssetManager assetManager = resources.getAssets();
			InputStream inputStream = assetManager.open("recorder.properties");
			Properties properties = new Properties();
			properties.load(inputStream);
			serverIP=properties.getProperty("SERVER_IP","10.0.2.2");
			port=properties.getProperty("SERVER_PORT","8080");
			sessionName=properties.getProperty("SESSION_NAME","bot-bot-recorder");
			serverName=properties.getProperty("SERVER_NAME","");
			System.out.println("The properties are now loaded");
			System.out.println("properties: " + properties);
		} catch (Exception err) {
			System.err.println("Failed to open microlog property file");
			err.printStackTrace();
		} 
	} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
		this.csvFilePath = csvFilePath;
		try { 
			Log.e("context", context.getPackageName());
			Resources res = context.getResources();
 
			AssetManager asset = res.getAssets();
			csvReader = new TestCSVReader(asset.open(csvFilePath));
 
		} catch (Exception e) {
			Log.e("csv cannot be read", e + " CSV");
			Assert.fail("Unable to read the csv file :" + e.toString());
		} 
		keySet = csvReader.getRow(0);
 
	} 
 
	public HashMap<String, String> getHashMapForRow(int rowNumber) {
		HashMap<String, String> data = new HashMap<String, String>();
		//setting test case name by taking the first parameter in the row 
		data.put("TestCaseName", csvReader.getData(rowNumber, 0));
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
	protected void setUp() throws Exception { 
		super.setUp(); 
		solo = new Solo(getInstrumentation(), getActivity());
		Context context=getInstrumentation().getContext();
		Resources resources =context.getResources();
		assetManager = resources.getAssets();
		prefrences.setExecutionContext(solo);
	} 
 
	@Override 
	protected void tearDown() throws Exception { 
		solo.finishOpenedActivities();
	} 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
	// Default ENUM suffixes are now defined in the db.ENUMSuffix class 
	//protected final static String ENUM_SUFFIXES = "enumSuffixes"; 
 
	public AppProperties(Context context) throws IOException {
		Resources resources = context.getResources();
		AssetManager assetManager = resources.getAssets();
 
		// Read from the /assets directory 
		InputStream inputStream = assetManager.open(FILENAME);
		load(inputStream);
		 
	} 
	 
	public String getRegistrationUrl() {
		return getProperty(REGISTRATION_URL);
	} 
	 
	public String getSipServer() {
		return getProperty(SIP_SERVER);
	} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
	 * @param filename 
	 *            the filename of the properties file used for configuration. 
	 */ 
	public void configure(String filename) {
		Resources resources = context.getResources();
		AssetManager assetManager = resources.getAssets();
		try { 
			InputStream inputStream = assetManager.open(filename);
			Properties properties = loadProperties(inputStream);
			startConfiguration(properties);
		} catch (IOException e) {
			Log.e(TAG, "Failed to open the microlog properties file. Hint: the file should be in the /assets directory "
					+ filename + " " + e);
		} 
	} 
 
	/** 
	 * Configure using the specified resource Id. 
	 *  
	 * @param resId 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAssets
 */ 
public class ResourcesWrapper extends Resources {
  private final Resources base;
 
  public ResourcesWrapper(Resources base) {
    super(base.getAssets(), null, null);
    this.base = base;
  } 
 
  public Resources getBase() {
    return base;
  } 
 
  @Override 
  public boolean equals(Object o) {
    return base.equals(o);
  } 
 
  @Override 
  public XmlResourceParser getAnimation(int id) throws NotFoundException {
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Resources getAssets Questions & Answers:

getAssets Method Overview
Retrieve underlying AssetManager storage for these resources.
See Code Examples for other Android Resources Methods: