Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.app.Application;
- import android.content.Context;
- import android.content.res.AssetManager;
- import android.util.Log;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Properties;
- import javax.inject.Inject;
- public class AssetsPropertyReader {
- private Context context;
- private Properties properties;
- public AssetsPropertyReader(Application application) {
- this.context = application.getApplicationContext();
- properties = new Properties();
- }
- public Properties getProperties(String FileName) {
- try {
- /**
- * getAssets() Return an AssetManager instance for your
- * application's package. AssetManager Provides access to an
- * application's raw asset files;
- */
- AssetManager assetManager = context.getAssets();
- /**
- * Open an asset using ACCESS_STREAMING mode. This
- */
- InputStream inputStream = assetManager.open(FileName);
- /**
- * Loads properties from the specified InputStream,
- */
- properties.load(inputStream);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- Log.e("AssetsPropertyReader",e.toString());
- }
- return properties;
- }
- }
Add Comment
Please, Sign In to add comment