本文整理了Java中android.app.Activity.openFileOutput()
方法的一些代码示例,展示了Activity.openFileOutput()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.openFileOutput()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:openFileOutput
暂无
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param name
* @param mode
* @return
* @throws FileNotFoundException
* @see android.content.ContextWrapper#openFileOutput(java.lang.String, int)
*/
public FileOutputStream openFileOutput(String name,
int mode) throws FileNotFoundException {
return mActivity.openFileOutput(name, mode);
}
代码示例来源:origin: powerpoint45/BasicLauncher
public static void serializeShortcutData(ShortcutSerializableData obj){
FileOutputStream fos;
try{
fos = MainActivity.activity.openFileOutput("shortcutdata", Context.MODE_PRIVATE);
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(obj);
os.close();
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}
}
代码示例来源:origin: powerpoint45/BasicLauncher
public static void serializeData(AppSerializableData obj){
FileOutputStream fos;
try{
fos = MainActivity.activity.openFileOutput("data", Context.MODE_PRIVATE);
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(obj);
os.close();
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}
}
代码示例来源:origin: seemoo-lab/fitness-app
/**
* Saves a string in the internal storage.
* @param string The data of the file.
* @param fileName The fileName of the file.
* @param activity The current activity.
*/
private static void save(String string, String fileName, Activity activity) {
try {
FileOutputStream outputStream = activity.openFileOutput(fileName, Context.MODE_PRIVATE);
outputStream.write(string.getBytes());
outputStream.close();
Log.e(TAG, "saved file on internal storage: " + fileName);
} catch (IOException e) {
Log.e(TAG, e.toString());
}
}
代码示例来源:origin: lessthanoptimal/BoofAndroidDemo
public void saveList() {
try {
FileOutputStream outputStream = owner.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
PrintStream out = new PrintStream(outputStream);
for( Info info : list ) {
// save the name at the end so I don't need to worry about parsing spaces and such
out.println(info.id+" "+info.sideLength+" "+info.units.name()+" "+info.name);
}
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* リソースから pbw ファイルを作成し、その uri を返す.
* @return uri を返す.
*/
@SuppressLint("WorldReadableFiles")
@SuppressWarnings("deprecation")
private static Uri getPbwFileName(final Activity activity) {
File file = activity.getFileStreamPath("dc_pebble.pbw");
try {
fileCopy(activity.getResources().openRawResource(R.raw.dc_pebble),
activity.openFileOutput(file.getName(), MODE_WORLD_READABLE));
} catch (IOException e) {
e.printStackTrace();
}
return Uri.fromFile(file);
}
代码示例来源:origin: AEFeinstein/mtg-familiar
/**
* Write the wishlist passed as a parameter to the wishlist file
*
* @param activity A context to open the file and pop toasts with
* @param lWishlist The wishlist to write to the file
*/
public static void WriteWishlist(Activity activity, ArrayList<MtgCard> lWishlist) {
try {
FileOutputStream fos = activity.openFileOutput(WISHLIST_NAME, Context.MODE_PRIVATE);
for (MtgCard m : lWishlist) {
fos.write(m.toWishlistString().getBytes());
}
fos.close();
} catch (IOException e) {
SnackbarWrapper.makeAndShowText(activity, e.getLocalizedMessage(), SnackbarWrapper.LENGTH_LONG);
}
}
代码示例来源:origin: lessthanoptimal/BoofAndroidDemo
public void addFiducial( GrayU8 image , double sideLength , UnitsDistance units ,
String name ) {
Info info = new Info();
info.id = selectUniqueId();
info.sideLength = sideLength;
info.units = units;
info.name = name;
list.add( info );
saveImage(image, info.id );
try {
FileOutputStream outputStream = owner.openFileOutput(FILE_NAME,
Context.MODE_PRIVATE | Context.MODE_APPEND );
PrintStream out = new PrintStream(outputStream);
out.println(info.id+" "+info.sideLength+" "+info.units.name()+" "+info.name);
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: AEFeinstein/mtg-familiar
/**
* Write the wishlist passed as a parameter to the wishlist file
*
* @param activity A context to open the file and pop toasts with
* @param mCompressedWishlist The wishlist to write to the file
*/
public static void WriteCompressedWishlist(Activity activity, ArrayList<CompressedWishlistInfo> mCompressedWishlist) {
if (null == activity) {
// Context is null, don't try to write the wishlist
return;
}
try {
FileOutputStream fos = activity.openFileOutput(WISHLIST_NAME, Context.MODE_PRIVATE);
/* For each compressed card, make an MtgCard and write it to the wishlist */
for (CompressedWishlistInfo cwi : mCompressedWishlist) {
for (IndividualSetInfo isi : cwi.mInfo) {
cwi.applyIndividualInfo(isi);
fos.write(cwi.toWishlistString().getBytes());
}
}
fos.close();
} catch (IOException e) {
SnackbarWrapper.makeAndShowText(activity, e.getLocalizedMessage(), SnackbarWrapper.LENGTH_LONG);
}
}
代码示例来源:origin: AEFeinstein/mtg-familiar
/**
* Write the decklist passed as a parameter to the decklist file.
*
* @param activity A context to open the file and pop toasts with
* @param lDecklist The decklist to write to the file
* @param fileName The name of the file to write the decklist to
*/
public static void WriteDecklist(
Activity activity,
ArrayList<MtgCard> lDecklist,
String fileName) {
try {
fileName = sanitizeFilename(fileName);
FileOutputStream fos = activity.openFileOutput(fileName, Context.MODE_PRIVATE);
for (MtgCard m : lDecklist) {
String cardString = m.toWishlistString();
/* If the card is a sideboard card, add the marking */
if (m.isSideboard()) {
cardString = "SB:" + cardString;
}
fos.write(cardString.getBytes());
}
fos.close();
} catch (IOException | IllegalArgumentException ioe) {
SnackbarWrapper.makeAndShowText(activity, ioe.getLocalizedMessage(), SnackbarWrapper.LENGTH_LONG);
}
}
代码示例来源:origin: bradand/XMouse
FileOutputStream fos = a.openFileOutput(lfile, Context.MODE_PRIVATE);
int foo;
while(true){
代码示例来源:origin: AEFeinstein/mtg-familiar
FileOutputStream fos = activity.openFileOutput(newFileName, Context.MODE_PRIVATE);
内容来源于网络,如有侵权,请联系作者删除!