How to write QFile in Blackberry 10 device? - blackberry-10

I am new in Blackberry 10, I want to create file in device document.
Does anyone knows how to do same?
Thanks in advance.

You can access device's Documents folder by using "/accounts/1000/shared/documents" path. You need access_shared permission to access the shared folders. You can find more information about BB10 file system here.
Following is sample code which shows how to write file using QFile.
QFile textfile("/accounts/1000/shared/documents/newfile.txt");
textfile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&textfile);
out << "This is a text file\n";
textfile.close();

Related

Is there a way to preview/open a file from a URL within the macCatalyst app without saving it in File system?

I'm trying to load/open/preview the files within the app but I don't want them to download and be saved in the file system to open them on MacCatalyst. I tried using QuickLook/QLPreviewController but it only works for files already stored in the File system.
I'm fairly new to MacCatalyst, any help is appreciated.

How can I open an external app with a file?

I have a question, I can't find the right one online.
I create a file and then want it to be opened by the app that matches the extension. Which should the user decide for himself if necessary. Such as e.g. opening an attachment in a mail.
Unfortunately, I can't find anything how I can persuade the system to do so with dart / flutter.
Can someone please help me.
Many thanks.
Mike
This plugin seems to do what you want
https://pub.dev/packages/open_file
Try to pass file path to open method as pecified in documentation
OpenFile.open("/sdcard/example.txt");

How to open/find the file created by path_provider?

I'm a beginner at flutter and dart and had some issues with file handling using flutter.
I'm trying to store data locally in text files for my flutter application, and came across the standard tutorial on flutter's website which used path_provider and dart:io. It had instructions on getting the path and reading and writing to a file, however this didn't seem to work for files I added to the project. The only way to store to files was to first write using the inbuilt functions, then reading this newly created file. I can't add my own file and read it using flutter.
I also can't open the file created by flutter as I don't know where its stored. The path given by getApplicationDocumentsDirectory() returns the path /data/user/0/com.example.daily_challenges/app_flutter, and I don't know where to find this in my project.
In summary: How do I read a pre-existing file and how do I view the file created automatically by flutter.
Thanks :)
You can access the files from a physical device or simulator through Device File Explorer in Android Studio. Follow this guide
You won't be able to access getApplicationDocumentsDirectory().
If you are using android device, you can try to store it in getExternalStorageDirectory(). There's no equivalent in IOS though.
If you are running in a physical device. Open Device File Explorer in Android Studio and you can find the file under
data/data/your app package/app_flutter/fileName.txt
For example,
data/data/com.example.file_example/app_flutter/example.txt
And if you want to read the pre-existing file, you not need to anything specific, if you give the same file name, if not exist, it will create one, otherwise it will return the old one.
final File file = File(filePath);
file.writeAsStringSync('${text}', mode: FileMode.append);
For write, you consider using FileMode if you want to append text to the existing file. Or else by default overwrite will happen.
For read, you can consider this
final File file = File(filePath);
String text = await file.readAsString();
Just use Device File Explorer from Android Studio.
But the weird thing, path_provider gives you path like /data/user/0/your_app_id/..., but in fact all files are located in /data/data/your_app_id/..., as mentioned in previous answer.

How do you create files in arbitrary locations using Swift?

How do you go about creating files at arbitrary locations given you have the absolute path? I want to create a file in some arbitrary location /Users/me/random/project3/<moreStuffInThePath. How would I go about doing this?
To create a directory I would do:
try FileManager.default.createDirectory(atPath: "/Users/me/random/project3/<directoryName>"
This worked fine for directories.
However the counterpart for creating files does not work:
FileManager.default.createFile(atPath: "Users/me/random/project3/something.txt", contents: someString.data(using: .utf8)) // always returns false
I have checked out other stack overflow threads on creating files. Everything I found was about creating files in the .documentDirectory or it was outdated.
Eg: How to create text file for writing
Create empty file swift
Read and write a String from text file
TLDR: How do I create text files/files with random extensions at arbitrary locations on the pc given I have the absolute path?
I would also be grateful if someone could explain why all tutorials available on this matter are about the document directory. Why is it so significant?
Thank you!
This is most likely because your app is sandboxed.
Go to your project settings, select the macOS target and go to "Signing and Capabilities". You should see something like this:
If your app needs to create files in arbitrary locations, you must remove the app sandbox by clicking on the "x" on the top right. Note that this will cause your app to be rejected from the Mac App Store.
If you want to upload your app to the Mac App Store, then you must keep the sandbox, and write to "user selected locations" only. Select "Read/Write" rather than "Read Only" next to "User Selected File". (Although it says "File", this includes directories too) This allows you to write to locations chosen by a user using something like an NSSavePanel.

.des files not opening in xcode

I have a problem that i want to open and edit some images of .png extension that are currently in .des extension (for example button_start.png is in the form button_start.des) when i open button_start.des in the xcode it just show a text file like this(button_start.png 12234.00132330122309.that is now of image along with a long numerical number or possibly a hash code) i had been trying to open this .des file with many softwares like coreldraw and quickbooks but it still dont open.It had been weeks but still i am not finding any solution.please guys help me to solve this problem. thanks
.des-files are 3D-project-files. Xcode can't read nor see them, so you need to open them in the application they were created in and export them as PNGs.
If you added the .des-ending manually to a .png-file, you could simply rename the file file.png and it will work.