本文整理了Java中android.app.Activity.openFileInput()
方法的一些代码示例,展示了Activity.openFileInput()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.openFileInput()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:openFileInput
暂无
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param name
* @return
* @throws FileNotFoundException
* @see android.content.ContextWrapper#openFileInput(java.lang.String)
*/
public FileInputStream openFileInput(String name) throws FileNotFoundException {
return mActivity.openFileInput(name);
}
代码示例来源:origin: seemoo-lab/fitness-app
/**
* Loads a file from internal storage
* @param fileName The fileName of the file.
* @param activity The current activity.
* @return The loaded file.
*/
private static String load(String fileName, Activity activity) {
String result = "";
try {
FileInputStream inputStream = activity.openFileInput(fileName);
byte[] input = new byte[inputStream.available()];
while (input.length !=0 && inputStream.read(input) != -1) {
result += new String(input);
}
inputStream.close();
} catch (FileNotFoundException e) {
Log.e(TAG, "No old file to load with key '" + fileName + "'");
return null;
} catch (IOException e) {
Log.e(TAG, e.toString());
return null;
}
Log.e(TAG, "loaded file from external storage: " + fileName);
return result;
}
代码示例来源:origin: powerpoint45/BasicLauncher
public static ShortcutSerializableData loadSerializedShortcutData(){
ObjectInputStream inputStram = null;
try{
inputStram = new ObjectInputStream(MainActivity.activity.openFileInput("shortcutdata"));
Object obj = inputStram.readObject();
if (obj instanceof ShortcutSerializableData){
return (ShortcutSerializableData)obj;
}else
return null;
}catch (EOFException e){
e.printStackTrace();
}catch (ClassNotFoundException e){
e.printStackTrace();
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}finally{
try{
if (inputStram!=null){
inputStram.close();
}
}catch (IOException e){
e.printStackTrace();
}
}
return null;
}
代码示例来源:origin: powerpoint45/BasicLauncher
inputStram = new ObjectInputStream(MainActivity.activity.openFileInput("data"));
Object obj = inputStram.readObject();
代码示例来源:origin: lessthanoptimal/BoofAndroidDemo
public void loadList() {
list.clear();
try {
FileInputStream inputStream = owner.openFileInput(FILE_NAME);
BufferedReader input = new BufferedReader(new InputStreamReader(inputStream));
while (true) {
String line = input.readLine();
if (line == null)
break;
Info info = new Info();
int where = findSpace(line, 0);
info.id = Integer.parseInt(line.substring(0, where));
int start = where + 1;
where = findSpace(line, where + 1);
info.sideLength = Double.parseDouble(line.substring(start, where));
start = where + 1;
where = findSpace(line, where + 1);
info.units = UnitsDistance.valueOf(line.substring(start, where));
info.name = line.substring(where + 1, line.length());
list.add(info);
}
inputStream.close();
} catch( FileNotFoundException ignore) {
Log.d(TAG,"Fiducial index file not found");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: AEFeinstein/mtg-familiar
/**
* Read the wishlist from a file and return it as an ArrayList<MtgCard>
*
* @param activity A context to open the file and pop toasts with
* @param loadFullData true to load all card data from the database, false to just read the file
* @return The wishlist in ArrayList form
*/
public static ArrayList<MtgCard> ReadWishlist(Activity activity, boolean loadFullData) throws FamiliarDbException {
ArrayList<MtgCard> lWishlist = new ArrayList<>();
int orderAddedIdx = 0;
try {
String line;
try (BufferedReader br = new BufferedReader(new InputStreamReader(activity.openFileInput(WISHLIST_NAME)))) {
/* Read each line as a card, and add them to the ArrayList */
while ((line = br.readLine()) != null) {
MtgCard card = MtgCard.fromWishlistString(line, false, activity);
card.setIndex(orderAddedIdx++);
lWishlist.add(card);
}
}
} catch (NumberFormatException e) {
SnackbarWrapper.makeAndShowText(activity, e.getLocalizedMessage(), SnackbarWrapper.LENGTH_LONG);
} catch (IOException e) {
/* Catches file not found exception when wishlist doesn't exist */
}
if (loadFullData && !lWishlist.isEmpty()) {
MtgCard.initCardListFromDb(activity, lWishlist);
}
return lWishlist;
}
代码示例来源:origin: AEFeinstein/mtg-familiar
try (BufferedReader br = new BufferedReader(new InputStreamReader(activity.openFileInput(deckName)))) {
boolean isSideboard;
代码示例来源:origin: ajavamind/Processing-Cardboard
stream = activity.openFileInput(filename);
if (stream != null) {
return stream;
内容来源于网络,如有侵权,请联系作者删除!