Languages

Menu
Sites
Language
File Manager

Hi!

I use template of Tab-based Application for File Manager app, first and second tabs are used by internal and external storages. Third tab is reserved by favorites from first and second tabs. It's pure native app.

Please prompt me how better to implement tab with favorites? Where need to save paths? How to load their on the tab? For first and second tabs it's simple - send path to external or internal storage in to Construct() method of Tizen::Io::Directory. But I don't understand how to get single path to many different paths of favorites. Yes, I know about Bookmark API, but JS not for me. May be such API as Bokmark API are implemented for C++ too?

With much regards.

Edited by: Anatoly Krasnovsky on 09 Sep, 2014
View Selected Answer

Responses

6 Replies
Alex Ashirov

Hi,

AFAIK there is no such C++ API like Bookmark. But you can use Tizen::App::AppRegistry to store the bookmarks and display them in the third tab. Also you can use SQL database for this purpose (Tizen::Io::Database).

Anatoly Krasnovsky

  Thanks for your answer, Alex.

  AppRegistry seems good for this task to store some text data as path and name. But my brain is crushed by ideas about one parent directory for all bookmarks. May you help me with some idea?

Alex Ashirov

Hi,

If I understand you correctly you want to store bookmarks somewhere in folder and read them from the folder to display in the 3rd tab. If so, you can create folder “Bookmarks” (e.g. “data” folder) and store each bookmark in a file (e.g. filename = name of bookmark, file content = path). I am not sure that this is graceful a solution but this should work.

Anatoly Krasnovsky

Thanks, Alex. Your answer is very helpful. But my knowledges in Tizen::IO not so good. Early I'm already tried to use File class and it was not successfully. Can you show me little sample?

Mark as answer
Alex Ashirov

Hi,

You can try sample function below. The function writes and reads to/from file.

#include <FBase.h>
#include <FIo.h>
#include <FApp.h>

using namespace Tizen::Base;
using namespace Tizen::Io;
using namespace Tizen::App;

int f() {
    String fileName(L"test.txt");
    String writeText(L"path");
    String readText;
    File file;
    result r = E_SUCCESS;

    // Creates file
    r = file.Construct(App::GetInstance()->GetAppDataPath() + fileName, "w+");
    if (IsFailed(r))
    {
        goto CATCH;
    }

    // Writes to the file
    file.Write(writeText);
    if (IsFailed(r))
    {
        goto CATCH;
    }

    // Repositions the file pointer
    r = file.Seek(FILESEEKPOSITION_BEGIN, 0);
    if (IsFailed(r))
    {
        goto CATCH;
    }

    // Reads
    file.Read(readText);
    r = GetLastResult();
    if (IsFailed(r))
    {
        goto CATCH;
    }

    // Checks the correctness of the read data
    if (readText != writeText)
    {
        goto CATCH;
    }
    AppLog("Succeeded!");
    return 0;

CATCH:
    AppLog("Failed...");
    return -1;
}

Anatoly Krasnovsky

Thank you for your care, Alex.