How to find directory for File Output Stream in Android app?How to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?How do I create a file and write to it in Java?Download a file with Android, and showing the progress in a ProgressDialogHow to avoid Java code in JSP files?Android SDK installation doesn't find JDKWhat's “tools:context” in Android layout files?Files saved to Cache dir are always MODE_PRIVATE?Calling OpenFileOutput inside a Button click listener in Android
Naming your baby - does the name influence the child?
is 1hr 15 minutes enough time to change terminals at Manila?
Was Apollo 13 radio blackout on reentry longer than expected?
''Habitable'' planet close to a star
I want to identify a part from a photo
Is it legal for a supermarket to refuse to sell an adult beer if an adult with them doesn’t have their ID?
What was the difference between a Games Console and a Home Computer?
How is the 'rate law' and 'order' for the ozone decomposition reaction can be defined?
Is surviving this (blood loss) scenario possible?
How to belay quickly ascending top-rope climbers?
Time signature inconsistent
Is it rude to refer to janitors as 'floor people'?
Term “console” in game consoles
Did 007 exist before James Bond?
How to remove the first colon ':' from a timestamp?
How can I help our ranger feel special about her beast companion?
May I use a railway velocipede on used British railways?
Exporting animation to Unity
why are fret buzz not going through the amp?
Desecrating Shabbos to ask a Gadol to daven for a patient?
Why were these characters absent in Spider-Man: Far From Home?
Finding all possible pairs of square numbers in an array
Arithmetics in LuaLaTeX
When can a polynomial be written as a polynomial function of another polynomial?
How to find directory for File Output Stream in Android app?
How to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?How do I create a file and write to it in Java?Download a file with Android, and showing the progress in a ProgressDialogHow to avoid Java code in JSP files?Android SDK installation doesn't find JDKWhat's “tools:context” in Android layout files?Files saved to Cache dir are always MODE_PRIVATE?Calling OpenFileOutput inside a Button click listener in Android
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have an app which gets data from an Arduino via bluetooth. The data are written into various ArrayLists and saved in files afterwards. Here is the code:
public boolean SaveValues(ArrayList<String> arrayList1, ArrayList<String> arrayList2, String valueType, String timeStart, String timeStop)
String filename = "File_" + valueType + "_" + timeStart + " bis " + timeStop;
FileOutputStream outputStream = null;
if(arrayList1.size() == 0)
return false;
try
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
for (int i = 0; i < arrayList1.size(); i++)
outputStream.write(arrayList1.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.write(arrayList2.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.close();
return true;
catch (FileNotFoundException e)
e.printStackTrace();
return false;
catch (IOException e)
e.printStackTrace();
return false;
finally
if (outputStream != null)
try
outputStream.close();
catch (IOException e)
e.printStackTrace();
I also save the valuetype, timeStart and timeStop into a database to be able to find the files. My problem is, that somehow the table where I save these values got deleted, so I am not able to find the files in the app. I would like to find the files maybe on the phone or something. Actually, I just need the filenames to be able to open them in the app, because they contain data I need. So, where can I find these files?
I have tried searching in the phones files. The files, and all the other apps data, should be saved in Android/data/package-name but I can't find the package name in Android/data. I also tried to search for "File_" in the files, because that's what every one of my files start with. But no file gets found.
java
|
show 8 more comments
I have an app which gets data from an Arduino via bluetooth. The data are written into various ArrayLists and saved in files afterwards. Here is the code:
public boolean SaveValues(ArrayList<String> arrayList1, ArrayList<String> arrayList2, String valueType, String timeStart, String timeStop)
String filename = "File_" + valueType + "_" + timeStart + " bis " + timeStop;
FileOutputStream outputStream = null;
if(arrayList1.size() == 0)
return false;
try
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
for (int i = 0; i < arrayList1.size(); i++)
outputStream.write(arrayList1.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.write(arrayList2.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.close();
return true;
catch (FileNotFoundException e)
e.printStackTrace();
return false;
catch (IOException e)
e.printStackTrace();
return false;
finally
if (outputStream != null)
try
outputStream.close();
catch (IOException e)
e.printStackTrace();
I also save the valuetype, timeStart and timeStop into a database to be able to find the files. My problem is, that somehow the table where I save these values got deleted, so I am not able to find the files in the app. I would like to find the files maybe on the phone or something. Actually, I just need the filenames to be able to open them in the app, because they contain data I need. So, where can I find these files?
I have tried searching in the phones files. The files, and all the other apps data, should be saved in Android/data/package-name but I can't find the package name in Android/data. I also tried to search for "File_" in the files, because that's what every one of my files start with. But no file gets found.
java
check whatgetFileStreamPath()returns
– pskink
Mar 26 at 8:27
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it togetFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.
– Apri
Mar 26 at 8:43
you dint have to create anything,openFileOutput()docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."
– pskink
Mar 26 at 8:47
My problem is, that I don't know the names of my files. The methodgetFileStreamPath()returns/data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is justAndroid/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.
– Apri
Mar 26 at 8:54
readContextjavadocs - it has a method that returns the parent folder - you can use that parent folder when calling one ofFile.list*methods
– pskink
Mar 26 at 8:55
|
show 8 more comments
I have an app which gets data from an Arduino via bluetooth. The data are written into various ArrayLists and saved in files afterwards. Here is the code:
public boolean SaveValues(ArrayList<String> arrayList1, ArrayList<String> arrayList2, String valueType, String timeStart, String timeStop)
String filename = "File_" + valueType + "_" + timeStart + " bis " + timeStop;
FileOutputStream outputStream = null;
if(arrayList1.size() == 0)
return false;
try
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
for (int i = 0; i < arrayList1.size(); i++)
outputStream.write(arrayList1.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.write(arrayList2.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.close();
return true;
catch (FileNotFoundException e)
e.printStackTrace();
return false;
catch (IOException e)
e.printStackTrace();
return false;
finally
if (outputStream != null)
try
outputStream.close();
catch (IOException e)
e.printStackTrace();
I also save the valuetype, timeStart and timeStop into a database to be able to find the files. My problem is, that somehow the table where I save these values got deleted, so I am not able to find the files in the app. I would like to find the files maybe on the phone or something. Actually, I just need the filenames to be able to open them in the app, because they contain data I need. So, where can I find these files?
I have tried searching in the phones files. The files, and all the other apps data, should be saved in Android/data/package-name but I can't find the package name in Android/data. I also tried to search for "File_" in the files, because that's what every one of my files start with. But no file gets found.
java
I have an app which gets data from an Arduino via bluetooth. The data are written into various ArrayLists and saved in files afterwards. Here is the code:
public boolean SaveValues(ArrayList<String> arrayList1, ArrayList<String> arrayList2, String valueType, String timeStart, String timeStop)
String filename = "File_" + valueType + "_" + timeStart + " bis " + timeStop;
FileOutputStream outputStream = null;
if(arrayList1.size() == 0)
return false;
try
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
for (int i = 0; i < arrayList1.size(); i++)
outputStream.write(arrayList1.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.write(arrayList2.get(i).getBytes());
outputStream.write("n".getBytes());
outputStream.close();
return true;
catch (FileNotFoundException e)
e.printStackTrace();
return false;
catch (IOException e)
e.printStackTrace();
return false;
finally
if (outputStream != null)
try
outputStream.close();
catch (IOException e)
e.printStackTrace();
I also save the valuetype, timeStart and timeStop into a database to be able to find the files. My problem is, that somehow the table where I save these values got deleted, so I am not able to find the files in the app. I would like to find the files maybe on the phone or something. Actually, I just need the filenames to be able to open them in the app, because they contain data I need. So, where can I find these files?
I have tried searching in the phones files. The files, and all the other apps data, should be saved in Android/data/package-name but I can't find the package name in Android/data. I also tried to search for "File_" in the files, because that's what every one of my files start with. But no file gets found.
java
java
edited Mar 26 at 9:03
Muhammad usman
16811 bronze badges
16811 bronze badges
asked Mar 26 at 8:22
ApriApri
748 bronze badges
748 bronze badges
check whatgetFileStreamPath()returns
– pskink
Mar 26 at 8:27
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it togetFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.
– Apri
Mar 26 at 8:43
you dint have to create anything,openFileOutput()docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."
– pskink
Mar 26 at 8:47
My problem is, that I don't know the names of my files. The methodgetFileStreamPath()returns/data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is justAndroid/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.
– Apri
Mar 26 at 8:54
readContextjavadocs - it has a method that returns the parent folder - you can use that parent folder when calling one ofFile.list*methods
– pskink
Mar 26 at 8:55
|
show 8 more comments
check whatgetFileStreamPath()returns
– pskink
Mar 26 at 8:27
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it togetFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.
– Apri
Mar 26 at 8:43
you dint have to create anything,openFileOutput()docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."
– pskink
Mar 26 at 8:47
My problem is, that I don't know the names of my files. The methodgetFileStreamPath()returns/data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is justAndroid/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.
– Apri
Mar 26 at 8:54
readContextjavadocs - it has a method that returns the parent folder - you can use that parent folder when calling one ofFile.list*methods
– pskink
Mar 26 at 8:55
check what
getFileStreamPath() returns– pskink
Mar 26 at 8:27
check what
getFileStreamPath() returns– pskink
Mar 26 at 8:27
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it to
getFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.– Apri
Mar 26 at 8:43
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it to
getFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.– Apri
Mar 26 at 8:43
you dint have to create anything,
openFileOutput() docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."– pskink
Mar 26 at 8:47
you dint have to create anything,
openFileOutput() docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."– pskink
Mar 26 at 8:47
My problem is, that I don't know the names of my files. The method
getFileStreamPath() returns /data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is just Android/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.– Apri
Mar 26 at 8:54
My problem is, that I don't know the names of my files. The method
getFileStreamPath() returns /data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is just Android/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.– Apri
Mar 26 at 8:54
read
Context javadocs - it has a method that returns the parent folder - you can use that parent folder when calling one of File.list* methods– pskink
Mar 26 at 8:55
read
Context javadocs - it has a method that returns the parent folder - you can use that parent folder when calling one of File.list* methods– pskink
Mar 26 at 8:55
|
show 8 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55352644%2fhow-to-find-directory-for-file-output-stream-in-android-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55352644%2fhow-to-find-directory-for-file-output-stream-in-android-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
check what
getFileStreamPath()returns– pskink
Mar 26 at 8:27
thanks! It returns /data/data/com.lis.lis/files/'filename'. But I have to create a new file and pass it to
getFilesStreamPath(). I don't know how I can find the old files, because when I go to the files on the phone, there is no /data/data/com.lis.lis.– Apri
Mar 26 at 8:43
you dint have to create anything,
openFileOutput()docs say: "Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist."– pskink
Mar 26 at 8:47
My problem is, that I don't know the names of my files. The method
getFileStreamPath()returns/data/data/com.lis.lis/files/'filename'. When I search in the phones internal storage, I can't find this path. There is justAndroid/data/, but in that directory I can't find the package-name of my app. So I don't know where I can find the files.– Apri
Mar 26 at 8:54
read
Contextjavadocs - it has a method that returns the parent folder - you can use that parent folder when calling one ofFile.list*methods– pskink
Mar 26 at 8:55