Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6173831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:38:36+00:00 2026-05-23T23:38:36+00:00

Since this turned out to be a long read, I’ll start with a very

  • 0

Since this turned out to be a long read, I’ll start with a very truncated version:

Are native processes not allowed to create/edit files created by their spawning java process regardless of having appropriate location/ permission/ file ownership?

The full question:

My application consists of a set of native binaries compiled with the NDK toolchain and a typical java Android interface. The native programs are packaged in the /assets folder and copied by the java application out into a /data/data/com.domain.app/nativeApplication folder.

There are two native application in question. One which modifies a jpeg created by the java layer, and a second which analyzes that jpeg and returns an int as output. The issue is this: When called by the java layer, the jpeg modifier doesn’t work.

I’ve done a good amount of troubleshooting on it already so I’ll try to dissuade you from some of the obvious potential answers starting with the most obvious.

Correct Compilation:
Through adb shell I can call both of the programs in question, as is, from the phone’s disk. The second image analyzer program runs without a hitch when called either via adb or as designed in the software IF I do the intermediary step manually from adb.

Permissions:

Jpg Permission – The application has permission to write to external storage. I’ve tried to have the file read in from both the SDcard and /data/data/com.domain.app/nativeApp/img/name.jpg; no joy. As stated the second program operates as designed when the image is in either location, if I manually run the first program through adb.

File/Folder Permissions: All of the folders in ~/nativeApplication/* have been created BY the android application itself, it is the owner and it has chmodded all of the sub-directories and files to 777.

Supporting Code:

Calling the jpg converter process:

NativeSetup.changePermission("/data/data/com.domain.program/nativeApp/img/img1.jpg");

try {    
            Process jpegConvert = Runtime.getRuntime().exec("/data/data/com.domain.program/nativeApp/bin/jpegtransformer -opts /data/data/com.domain.program/nativeApp/img/img1.jpg > /data/data/com.domain.program/nativeApp/img/img2.jpg");
            jpegConvert.waitFor();          
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

Call used to create the files in ~/nativeApp/*

private static void copyFile(String assetPath, String localPath, Context context) {

    try {
        InputStream in = context.getAssets().open(assetPath);
        FileOutputStream out = new FileOutputStream(localPath);
        int read;
        byte[] buffer = new byte[4096];
        while ((read = in.read(buffer)) > 0) {
            out.write(buffer, 0, read);
        }

chmod call: (it works according to ls -l through adb)

static void changePermission(String localPath) {

    try {
        Process chmod = Runtime.getRuntime().exec("/system/bin/chmod 777 " +localPath);
        chmod.waitFor();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
        out.close();
        in.close();


    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

Permissions of the file the program can’t edit and then output a changed copy:

~/nativeApp/img $ ls -l
-rwxrwxrwx app_89   app_89      93061 2011-07-23 18:38 img1.jpg

Permission of the application that can’t edit the above jpg:

~/nativeApp/bin $ ls -l jpegtransformer
-rwxrwxrwx app_89   app_89      95268 2011-07-23 18:01 jpegtransformer

Permissions of folders in ~/nativeApp/
~/nativeApp $ ls -l
drwxrwxrwx app_89 app_89 2011-07-23 17:57 bin
drwxrwxrwx app_89 app_89 2011-07-23 18:27 img

Theories:

At this point my only viable theory is that there is some android policy not governed by chmod which is keeping the jpegtransformer from editing the image when called by the java layer. Since the image analyzer doesn’t change the image I imagine it skirts this? Are native processes not allowed to create files? Any ideas would be great. Sorry for the long read.

-SS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:38:37+00:00Added an answer on May 23, 2026 at 11:38 pm

    I think your problem is not related to permissions – you try to redirect the output using >, while this is a shell operator and does not work from java. grab the process output stream and write it to a file using Java standard file I/O API.

    Though I’m not sure this is the problem, you shouldn’t have problem to modify files in your app folder and the issue I described is an issue I met more than once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently spent a long while debugging something that turned out to be an
I need to know this since this is a pre-req for .NET 3.5 and
Im just starting a project and since this project is personal I was wondering
I need to migrate Access databases to SQL Server 2005. Since this needs to
OK I'm redoing this since I messed it up. :) here's the xaml. <Window
Ok, I've run across my first StackOverflowError since joining this site, I figured this
Similar to this question, but for VB.NET since I learned this is a language
Since I have started using this site, I keep hearing about the Boost library.
This might seem like a ridiculous question since I'm quite inexperienced in .NET. Is
I have this syntax which works (since it's from the API, pretty much) <%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.